Questions tagged [keras-2]

with a new API.

Keras API will now become available directly as part of

264 questions
1
vote
0 answers

Implementing LSTM based Siamese NN architecture

Problem is to compare a given student answer to faculty given the modal answer or correct answer and assign grades to the student answer. After researching a lot, Siamese architecture with LSTMs seems to be a very good choice for the neural network…
1
vote
1 answer

Saving DNN model saves 3 files. How to load?

I trained a DNN using Keras. However, I am unable to save and load the model. from keras.models import load_model model.save('/home/ubuntu/pynb/savedmodel.tfl') #model.load('/home/ubuntu/pynb/savedmodel.tfl') But I find that instead of…
rajkiran
  • 332
  • 3
  • 14
1
vote
1 answer

Migrating keras.backend.conv2d from Keras 1.x to 2.x

I'm migrating a project from Keras 1.x to 2.x. In the code, a keras.backend.conv2d operation that was running fine in 1.x now crashes in 2.x. convs = K.conv2d(a, b, padding='valid', data_format='channels_first') Input tensors shapes a and b are…
Overdrivr
  • 6,296
  • 5
  • 44
  • 70
1
vote
2 answers

How to resize (interpolate) a tensor in Keras?

I want to resize a tensor (between layers) of size say (None, 2, 7, 512) to (None, 2, 8, 512), by interpolating it (say using nearest neighbor), similar to this function tf.image.resize_nearest_neighbor available in Tensorflow. Is there any way to…
ArunKumar
  • 105
  • 1
  • 12
1
vote
1 answer

Error in creating custom initializer using get_variable with Keras

I created a custom initializer with Keras. Part of the code is: def my_init(shape): P = tf.get_variable("P", shape=shape, initializer = tf.contrib.layers.xavier_initializer()) return P model = Sequential() model.add(Conv2D(32,…
Darshi
  • 55
  • 4
1
vote
1 answer

What causes high top_k_categorical_accuracy but low categorical_accuracy in Keras

I'm training a model using Conv2D and started to suddenly get a high top k categorical accuracy that is 1.0 but very low categorical accuracy (close to 0.006). I have 108 different categories so the only thing I can think of that would cause it is…
Daniel O
  • 4,607
  • 6
  • 44
  • 52
1
vote
2 answers

Python - Tensorflow - LSTM- ValueError: Error when checking model target: expected dense_16 to have shape (None, 100) but got array with shape (16, 2)

Could someone help me to understand what this error is all about? model = Sequential() model.add(Embedding(82, 100, weights=[embedding_matrix], input_length=1000)) model.add(LSTM(100)) model.add(Dense(100, activation =…
Doubt Dhanabalu
  • 457
  • 4
  • 8
  • 18
1
vote
1 answer

NN Batch and Training accuracy

I have NN based on InceptionV3. Feeding it batches during epochs gives good results like: loss: 0.3596 - acc: 0.8479 - val_loss: 0.3442 - val_acc: 0.8515 After training was done I have decided to check training accuracy on the whole training…
1
vote
1 answer

Keras - Use tensor shape for K.zeros shape

I am using custom softmax function. I am trying to use shape of tensor x as an element of shape of new tensor of zeros. It can not be done since it is not int. def custom_softmax(x): sh = K.shape(x) ... xc = K.zeros((sh[0] * 16 *…
Primoz
  • 1,324
  • 2
  • 16
  • 34
1
vote
1 answer

Can I use Tensorflow and Keras interchangeably?

I am using l2_regularization Tensorflow has - tf.nn.l2_loss Can I use this? K.sum(K.square(K.abs(Weights))) tf.nn.l2_loss Can I use this interchangeably in Keras (Tensorflow backend)?
1
vote
1 answer

Keras ValueError: fit_generator yielding a list

I'm learning how to work with Keras with TF backend for image recognition so I'm still not sure about what am I doing wrong here. I'm trying to stack 2 models, one being VGG16, and the other one being a random one I made just to learn how to stack…
htcoelho
  • 65
  • 7
1
vote
1 answer

'KerasRegressor' object has no attribute 'to_json'

I'm unable to save the model trained using KerasRegressor wrapper... model = KerasRegressor(build_fn=base_model, epochs=1, batch_size=10, verbose=1) model.fit(X,Y) model_json = model.to_json() with open("model.json", "w") as json_file: …
Progeny
  • 672
  • 1
  • 11
  • 25
1
vote
1 answer

Training sparse model with Keras

I'm trying to train a sparse model, that is some of the model parameters have to remain zero during optimization. Is this possible in Keras to define a mask for the parameters so that the optimizer would not update masked ones? Unfortunately,…
soroosh.strife
  • 1,181
  • 4
  • 19
  • 45
1
vote
1 answer

PReLU with variable input size

How can I use the PReLU activation function with an variable input size? from keras.layers import Conv2D, Input from keras.layers.advanced_activations import PReLU X = Input(shape=(None,None,1)) conv1Y = Conv2D(filters=49, kernel_size=7,…
Manuel Schmidt
  • 2,429
  • 1
  • 19
  • 32
1
vote
2 answers

Disable Keras batch normalization/standardization

I am using a simple Keras model for series prediction. I am feeding it input normalized across the entire series. The model prediction accuracy seems to be correct during training. However, when I plot the outputs of the model.predict() function, I…
Igor Ševo
  • 5,459
  • 3
  • 35
  • 80