keras

Confused about keras Dot Layer. How is the Dot product computed?

て烟熏妆下的殇ゞ 提交于 2021-01-27 10:43:17
问题 I read all posts about the Dot Layer but none explains how this and so the output shape is computed! It seems so standard though! How exactly are the values computed with a along a specific axis? val = np.random.randint(2, size=(2, 3, 4)) a = K.variable(value=val) val2 = np.random.randint(2, size=(2, 2, 3)) b = K.variable(value=val) print("a") print(val) print("b") print(val2) out = Dot(axes = 2)([a,b]) print(out.shape) print("DOT") print(K.eval(out)) I get: a [[[0 1 1 1] [1 1 0 0] [0 0 1 1]]

Different accuracy by fit() and evaluate() in Keras with the same dataset

青春壹個敷衍的年華 提交于 2021-01-27 07:06:58
问题 I program Keras's code to train GoogleNet. However, accuracy gotten from fit() is 100% yet with the same training dataset used for evaluate(), accuracy remains 25% only, which has such huge discrepancy!!! Also, accuracy by evaluate(), which is not like fit(), won't get improved for training more times, which means it almost stays in 25%. Does anyone has idea of what is wrong with this situation? # Training Dataset and labels r given. Here load GoogleNet model from keras.models import load

Keras creating three classes instead of two

那年仲夏 提交于 2021-01-27 06:51:07
问题 I am trying to train a model to identify images containing fire VS images that contain forests. I am training the model on a remote server using Linode. I am using Python 2.7 and Ubuntu 16.04.5. When i run the following code locally or in Jupyter notebooks it will create 2 classes, but when i want to run it on the server it creates 3 classes. The code that classifies the model: def onehot(x): return np.array(OneHotEncoder().fit_transform(x.reshape(-1,1)).todense()) model = keras.applications

How to implement RBF activation function in Keras?

时光怂恿深爱的人放手 提交于 2021-01-27 06:47:48
问题 I am creating a customized activation function, RBF activation function in particular: from keras import backend as K from keras.layers import Lambda l2_norm = lambda a,b: K.sqrt(K.sum(K.pow((a-b),2), axis=0, keepdims=True)) def rbf2(x): X = #here i need inputs that I receive from previous layer Y = # here I need weights that I should apply for this layer l2 = l2_norm(X,Y) res = K.exp(-1 * gamma * K.pow(l2,2)) return res The function rbf2 receives the previous layer as input: #some keras

Keras creating three classes instead of two

。_饼干妹妹 提交于 2021-01-27 06:46:08
问题 I am trying to train a model to identify images containing fire VS images that contain forests. I am training the model on a remote server using Linode. I am using Python 2.7 and Ubuntu 16.04.5. When i run the following code locally or in Jupyter notebooks it will create 2 classes, but when i want to run it on the server it creates 3 classes. The code that classifies the model: def onehot(x): return np.array(OneHotEncoder().fit_transform(x.reshape(-1,1)).todense()) model = keras.applications

InvalidArgumentError: Specified a list with shape [60,9] from a tensor with shape [56,9]

一个人想着一个人 提交于 2021-01-27 06:38:23
问题 After running my model for one epoch it crashed with following error message: InvalidArgumentError: Specified a list with shape [60,9] from a tensor with shape [56,9] [[{{node TensorArrayUnstack/TensorListFromTensor}}]] [[sequential_7/lstm_17/PartitionedCall]] [Op:__inference_train_function_29986] This happened after I changed the LSTM Layer to stateful=True and had to pass the batch_input_shape Argument instead of the input_shape Below is my code, I'm sure it has something to do with the

keras ImageDataGenerator interpolates binary mask

你离开我真会死。 提交于 2021-01-27 06:34:13
问题 I am training a neural network to predict a binary mask on mouse brain images. For this I am augmenting my data with the ImageDataGenerator from keras. But I have realized that the Data Generator is interpolating the data when applying spatial transformations. This is fine for the image, but I certainly do not want my mask to contain non-binary values. Is there any way to choose something like a nearest neighbor interpolation when applying the transformations? I have found no such option in

Keras model.predict always 0

人走茶凉 提交于 2021-01-27 06:00:55
问题 I am using keras applications for transfer learning with resnet 50 and inception v3 but when predicting always get [[ 0.]] The below code is for a binary classification problem. I have also tried vgg19 and vgg16 but they work fine, its just resnet and inception. The dataset is a 50/50 split. And I am only changing the model = applications.resnet50.ResNet50 line of code for each model. below is the code: from keras.callbacks import EarlyStopping early_stopping = EarlyStopping(monitor='val_loss

Keras model.predict always 0

帅比萌擦擦* 提交于 2021-01-27 05:58:31
问题 I am using keras applications for transfer learning with resnet 50 and inception v3 but when predicting always get [[ 0.]] The below code is for a binary classification problem. I have also tried vgg19 and vgg16 but they work fine, its just resnet and inception. The dataset is a 50/50 split. And I am only changing the model = applications.resnet50.ResNet50 line of code for each model. below is the code: from keras.callbacks import EarlyStopping early_stopping = EarlyStopping(monitor='val_loss

indices[201] = [0,8] is out of order. Many sparse ops require sorted indices.Use `tf.sparse.reorder` to create a correctly ordered copy

十年热恋 提交于 2021-01-27 05:06:56
问题 Im doing a neural network encoding every variable and when im going to fit the model, an error raises. indices[201] = [0,8] is out of order. Many sparse ops require sorted indices. Use `tf.sparse.reorder` to create a correctly ordered copy. [Op:SerializeManySparse] I dunno how to solve it. I can print some code here and if u want more i can still printing it def process_atributes(df, train, test): continuas = ['Trip_Duration'] cs = MinMaxScaler() trainCont = cs.fit_transform(train[continuas])