Questions tagged [keras-layer]

1512 questions
21
votes
1 answer

Keras error "You must feed a value for placeholder tensor 'bidirectional_1/keras_learning_phase' with dtype bool"

I get the following error for the code snippet below: You must feed a value for placeholder tensor 'bidirectional_1/keras_learning_phase' with dtype bool If I add the dropout layer model.add(Dropout(dropout)), it works. Anyone knows why? The…
wolfshow
  • 211
  • 1
  • 2
  • 6
21
votes
1 answer

Resizing an input image in a Keras Lambda layer

I would like my keras model to resize the input image using OpenCV or similar. I have seen the use of ImageGenerator, but I would prefer to write my own generator and simply resize the image in the first layer with keras.layers.core.Lambda. How…
Sam Hammamy
  • 10,819
  • 10
  • 56
  • 94
21
votes
2 answers

How do you make TensorFlow + Keras fast with a TFRecord dataset?

What is an example of how to use a TensorFlow TFRecord with a Keras Model and tf.session.run() while keeping the dataset in tensors w/ queue runners? Below is a snippet that works but it needs the following improvements: Use the Model API specify…
Andrew Hundt
  • 2,551
  • 2
  • 32
  • 64
20
votes
1 answer

How to set the input of a Keras layer with a Tensorflow tensor?

In my previous question, I used Keras' Layer.set_input() to connect my Tensorflow pre-processing output tensor to my Keras model's input. However, this method has been removed after Keras version 1.1.1. How can I achieve this in newer Keras…
Qululu
  • 1,040
  • 2
  • 12
  • 23
19
votes
1 answer

How to check the weights after every epoc in Keras model

I am using the sequential model in Keras. I would like to check the weight of the model after every epoch. Could you please guide me on how to do so. model = Sequential() model.add(Embedding(max_features, 128, dropout=0.2)) model.add(LSTM(128,…
Kiran Baktha
  • 627
  • 2
  • 9
  • 20
18
votes
1 answer

Where is the tensorflow session in Keras

I'm new to keras and tensorflow. When I write programs with tensorflow, I must bulid a session to run the graph. However, when I use keras, although the backend is obviously tensorflow, I don't see session in the keras code. It seems all thing is…
LinTIna
  • 481
  • 1
  • 6
  • 14
18
votes
2 answers

How to correctly get layer weights from Conv2D in keras?

I have Conv2D layer defines as: Conv2D(96, kernel_size=(5, 5), activation='relu', input_shape=(image_rows, image_cols, 1), kernel_initializer=initializers.glorot_normal(seed), …
Vladimir Tsyshnatiy
  • 989
  • 1
  • 10
  • 20
17
votes
4 answers

Keras - ImportError: cannot import name 'CuDNNLSTM'

I am trying to use the CuDNNLSTM Keras cell to improve training speed for a recurrent neural network (doc here). When I run: from keras.layers import Bidirectional, CuDNNLSTM I get this error: ImportError: cannot import name 'CuDNNLSTM' My…
Marvin Lerousseau
  • 451
  • 1
  • 5
  • 10
16
votes
1 answer

What is the difference between SeparableConv2D and Conv2D layers?

I didn't find a clearly answer to this question online (sorry if it exists). I would like to understand the differences between the two functions (SeparableConv2D and Conv2D), step by step with, for example a input dataset of (3,3,3) (as RGB…
etiennedm
  • 409
  • 1
  • 3
  • 9
15
votes
2 answers

Keras Concatenate Layers: Difference between different types of concatenate functions

I just recently started playing around with Keras and got into making custom layers. However, I am rather confused by the many different types of layers with slightly different names but with the same functionality. For example, there are 3…
Lim Kaizhuo
  • 714
  • 3
  • 7
  • 16
15
votes
2 answers

ValueError: Unknown layer: CapsuleLayer

I have defined a custom layer named CapsuleLayer. The actual model has been defined in a separate class. I have loaded the weights into the actual model and have saved the model in an .h5 file. However when I try to load the model using…
Sounak Ray
  • 303
  • 1
  • 3
  • 9
15
votes
3 answers

Keras: Lambda layer function with multiple parameters

I am trying to write a Lambda layer in Keras which calls a function connection, that runs a loop for i in range(0,k) where k is fed in as an input to the function, connection(x,k). Now, when I try to call the function in the Functional API, I tried…
Prabaha
  • 879
  • 2
  • 9
  • 19
15
votes
4 answers

ImportError: No module named 'keras.utils.visualize_util'

Hi when I am trying to run a code in keras it is showing me the following error: from keras.utils.visualize_util import plot ImportError: No module named 'keras.utils.visualize_util' How can I solve this? thanks
S.EB
  • 1,966
  • 4
  • 29
  • 54
15
votes
3 answers

Can't change activations in existing Keras model

I have a normal VGG16 model with relu activations, i.e. def VGG_16(weights_path=None): model = Sequential() model.add(ZeroPadding2D((1, 1),input_shape=(3, 224, 224))) model.add(Convolution2D(64, 3, 3, activation='relu')) …
RickOrMorty
  • 151
  • 1
  • 5
14
votes
3 answers

How do I load a keras saved model with custom Optimizer

I have compiled and trained a keras model with a custom optimizer. I saved the model but when I try to load the model, it throws an error stating ValueError: Unknown optimizer: MyOptimizer. I tried to pass MyOptimizer as a custom object something…
Delta
  • 161
  • 1
  • 8