Questions tagged [keras-layer]
1512 questions
6
votes
2 answers
Conv1D on 2D input
Can someone explain to me what happens when a keras Conv1D layer is fed 2D input?
Such as:
model=Sequential()
model.add(Conv1D(input_shape=(9000,2),kernel_size=200,strides=1,filters=20))
Varying the input size between (9000,1) and (9000,2) and…

Kaare
- 531
- 1
- 7
- 26
6
votes
3 answers
Keras - Pop and re-add layers, but layer does not disconnect
Using Keras (1.2.2), I am loading a sequential model whose last layers are:
model.add(Dense(512))
model.add(Activation('relu'))
model.add(Dense(nb_classes))
model.add(Activation('softmax'))
Then, I want to pop the last layer, add another fully…

Béatrice Moissinac
- 934
- 2
- 16
- 41
6
votes
3 answers
Change input tensor shape for VGG16 application
I want to feed images with the shape (160,320,3) to
VGG16(input_tensor=input_tensor, include_top=False)
How can I include a layer that reshapes the images to the shape expected by the VGG16 model, which is (224,224,3) ?

Oblomov
- 8,953
- 22
- 60
- 106
6
votes
3 answers
Keras - Fusion of a Dense Layer with a Convolution2D Layer
I want to make a custom layer which is supposed to fuse the output of a Dense Layer with a Convolution2D Layer.
The Idea came from this paper and here's the network:
the fusion layer tries to fuse the Convolution2D tensor (256x28x28) with the Dense…

Cypher
- 2,374
- 4
- 24
- 36
6
votes
1 answer
Stateful LSTM with Embedding Layer (shapes don't match)
I am trying to build a stateful LSTM with Keras and I don't understand how to add a embedding layer before the LSTM runs. The problem seems to be the stateful flag. If my net is not stateful adding the embedding layer is quite straight forward and…

toobee
- 2,592
- 4
- 26
- 35
6
votes
1 answer
Keras remove layers after model.fit()
I'm using Keras to do the modelling works and I wonder is it possible to remove certain layers by index or name? Currently I only know the model.pop() could do this work but it just removes the most recently added layers. In addition, layers is the…

Ludwig Zhou
- 1,026
- 1
- 11
- 23
5
votes
1 answer
How does Embedding layer in Keras work on float input values?
x is a (64, 1) dimensional vector created randomly using tf.random.uniform((BATCH_SIZE, 1)), where the BATCH_SIZE = 64.
A random initialization looks like this:
tf.Tensor(
[[0.76922464]
[0.7928164 ]
[0.91224647]
[0.41210544]
[0.33040464]
…

Utpal Mattoo
- 890
- 3
- 17
- 41
5
votes
2 answers
keras : add layers to another model
I need to add layers to an existing model. However, I need to add the layers at "the main model level", that is I can't use the classic functional approach. For example, if I use something like:
from keras.layers import Dense,Reshape, Input
inp =…

volperossa
- 1,339
- 20
- 33
5
votes
2 answers
AttributeError: module 'tensorflow.python.keras.backend' has no attribute 'get_graph'
I have been working on keras yolov3 model for object detection. This error keeps showing up.
Here is the error:
AttributeError: module 'tensorflow.python.keras.backend' has no attribute 'get_graph'
I don't know what to do. I have tried replacing…

Abu Noman Md Sakib
- 322
- 2
- 5
- 20
5
votes
1 answer
How do I find the non differentiable operation in my layer?
I am trying to create a rather complex lambda-layer with many operations in keras. After I implemented it, I got a ValueError: No gradients provided for any variable.
While I am using only keras operations to transform the data, (except for a…

McLP
- 140
- 14
5
votes
1 answer
CNN autoencoder with non square images
I have implemented a variational autoencoder with CNN layers for the encoder and decoder. The code is shown below. My training data (train_X) consists of 40'000 images with size 64 x 78 x 1 and my validation data (valid_X) consists of 4500 images of…

machinery
- 5,972
- 12
- 67
- 118
5
votes
1 answer
Keras 2: Using lambda function in "Merge" layers
I am trying to implement this merge layer:
policy = merge([out1, out2], mode = lambda x: x[0]-K.mean(x[0])+x[1], output_shape = (out_node,))
However, "merge" is no longer present in Keras 2. You can only access public standarized "Merge" layers,…

olinarr
- 261
- 3
- 13
5
votes
3 answers
how do I implement Gaussian blurring layer in Keras?
I have an autoencoder and I need to add a Gaussian noise layer after my output. I need a custom layer to do this, but I really do not know how to produce it, I need to produce it using tensors.
what should I do if I want to implement the above…

david
- 1,255
- 4
- 13
- 26
5
votes
0 answers
keras.backend.function return a AttributeError: Layer dense is not connected, no input to return
I want to know the median result of a neutral network for tuning purpose. I design my model and use keras.backend.function but failed(AttributeError: Layer dense is not connected, no input to return). Here is my example:
import tensorflow as tf
from…

nan
- 401
- 4
- 13
5
votes
0 answers
Is there a method to find the min, max of a Tensorflow/Keras layer input during training?
Is there an option to find the min, max range of the input, of a Keras/Tensorflow layer where the output of the min, max range calculation is a float?
E.g. I want to know this range for the tf.fake_quant_with_min_max_args() function, where min, max…

michelvl92
- 61
- 6