keras

Input multiple datasets to tensorflow model

ぃ、小莉子 提交于 2021-01-29 10:30:33
问题 Hi I'm trying to input multiple datasets in a model. This is an example of my problem, however in my case one of my models has 2 input parameters while the other one has one. The error I get in my case is : Failed to find data adapter that can handle input: (<class 'list'> containing values of types {"<class 'tensorflow.python.data.ops.dataset_ops.BatchDataset'>", "<class 'tensorflow.python.data.ops.dataset_ops.TakeDataset'>"}), <class 'NoneType'> Code: import tensorflow as tf # Create first

How do I get reproducible results with Tensorflow 2.0?

时光总嘲笑我的痴心妄想 提交于 2021-01-29 10:23:12
问题 I have seen this FAQ and this stackoverflow about reproducibility in keras and TF 1.x. How do I do something similar in TF 2.0 because it no longer has tf.Session ? I know I could still set the graph seed and the seed for each initialization in the layer by passing something like tf.keras.initializers.GlorotNormal(seed=10) . However, I am wondering if there is something more convenient. 回答1: Consider using tf.random.set_seed(seed) at the startup. In my use cases it provides reproducible

Getting true labels for keras predictions

时光怂恿深爱的人放手 提交于 2021-01-29 10:15:17
问题 I have a standard CNN for image classification, using the following generator to get the dataset: generator = validation_image_generator.flow_from_directory(batch_size=BATCH_SIZE, directory=val_dir, shuffle=False, target_size=(100,100), class_mode='categorical') I can easily get the predicted labels with: predictions = model.predict(dataset) Now I want to get the (original) true labels and images for all the predictions, in the same order as the predictions in order to compare them. I am sure

Graph disconnected: cannot obtain value for tensor Tensor(“conv2d_1_input:0”, shape=(?, 128, 128, 1), dtype=float32)

时间秒杀一切 提交于 2021-01-29 10:01:26
问题 I'm trying to implement an autoencoder which gets 3 different inputs and fuse this three image. I want to get the output of a layer in the encoder and concatenate it with a layer in the decoder but when I run it I get graph disconnected error. here is my code: def create_model(input_shape): input_1 = keras.layers.Input(input_shape) input_2 = keras.layers.Input(input_shape) input_3 = keras.layers.Input(input_shape) network = keras.models.Sequential([ keras.layers.Conv2D(32, (7, 7), activation

Why does python fail when loading data set “.load_data()”

我只是一个虾纸丫 提交于 2021-01-29 09:47:52
问题 here is my code import tensorflow as tf from tensorflow import keras import numpy as np import matplotlib.pyplot as plt data = keras.datasets.fashion_mnist (train_images, train_labels), (test_images, test_labels) = data.load_data() and it is giving me this long scary error: Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/train-labels-idx1-ubyte.gz Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib

How to use many-to-one LSTM with variable-length input on Keras?

て烟熏妆下的殇ゞ 提交于 2021-01-29 09:33:58
问题 I have a multi-class sequence labeling problem where the number of time steps varies within samples. To use LSTM with variable-length input, I applied zero padding and masking to my input. I've read here that propagation of the mask stops after using LSTM layer with return_sequence=False parameter, that part confused me. My question is, would it be okay to use LSTM with return_sequence=False to calculate loss correctly for the below architecture ? from tensorflow.keras.layers import LSTM,

Train accuracy decreases with train loss

本秂侑毒 提交于 2021-01-29 09:32:54
问题 I wrote this very simple code model = keras.models.Sequential() model.add(layers.Dense(13000, input_dim=X_train.shape[1], activation='relu', trainable=False)) model.add(layers.Dense(1, input_dim=13000, activation='linear')) model.compile(loss="binary_crossentropy", optimizer='adam', metrics=["accuracy"]) model.fit(X_train, y_train, batch_size=X_train.shape[0], epochs=1000000, verbose=1) The data is MNIST but only for digits '0' and '1'. I have a very strange issue, where the loss is

TypeError: 'Tensor' object is not callable | Keras-Bert

守給你的承諾、 提交于 2021-01-29 09:31:13
问题 I'm building this model: inputs = model.inputs[:2] layer_output = model.get_layer('Encoder-12-FeedForward-Norm').output input_layer= keras.layers.Input(shape=(SEQ_LEN,768))(layer_output) conv_layer= keras.layers.Conv1D(100, kernel_size=3, activation='relu', data_format='channels_first')(input_layer) maxpool_layer = keras.layers.MaxPooling1D(pool_size=4)(conv_layer) flat_layer= keras.layers.Flatten()(maxpool_layer) outputs = keras.layers.Dense(units=3, activation='softmax')(flat_layer) model =

Error after combination of two Keras models into VAE: You must feed a value for placeholder tensor 'critic_input_2'

只愿长相守 提交于 2021-01-29 09:30:17
问题 Trying combine GAN generator and critic to train both as VAE. Base code is here. Code modified to create encoder on top of critic: def _build_critic(self): #### THE critic critic_input = Input(shape=self.input_dim, name='critic_input') x = critic_input for i in range(self.n_layers_critic): x = Conv2D( filters = self.critic_conv_filters[i] , kernel_size = self.critic_conv_kernel_size[i] , strides = self.critic_conv_strides[i] , padding = 'same' , name = 'critic_conv_' + str(i) , kernel

Keras Sequential Model-SGD- Neural Network-NLTK

女生的网名这么多〃 提交于 2021-01-29 09:29:31
问题 creating a bot, Here i faced error after training. i trained using the Keras SEQUENTIAL Model, SGD Optimizer, NLTK lemmatizer =WordNetLemmatizer() words =pickle.load(open("words.pkl",'rb'))# reading binary mode classes= pickle.load(open("classes.pkl",'rb')) model =load_model('chatbot.model') print(classes) def clean_up_sentence(sentence): sentence_words =nltk.word_tokenize(sentence) sentence_words=[lemmatizer.lemmatize(word) for word in sentence_words] return sentence_words def bag_of_words