Questions tagged [keras-layer]
1512 questions
5
votes
1 answer
In Keras, how to use Reshape layer with None dimension?
In my model, a layer has a shape of [None, None, 40, 64]. I want to reshape this into [None, None, 40*64]. However, if I simply do the following:
reshaped_layer = Reshape((None, None, 40*64))(my_layer)
It throws an error complaining that None…

foobar
- 10,854
- 18
- 58
- 66
5
votes
0 answers
keras: record layer-wise learning rate
I'm implementing a simple CNN with Keras, and trying to set up layer-wise learning rate in Adam. I take a reference of this tutorial. The revised Adam as shown below:
class Adam_lr_mult(Optimizer):
def __init__(self, lr=0.001, beta_1=0.9,…

Henry Chang
- 61
- 4
5
votes
1 answer
Implementing Seq2Seq with GRU in Keras
I implanted the ten-minutes LSTM example from the Keras site and adjusted the network to handle word embeddings instead of character ones (from https://blog.keras.io/a-ten-minute-introduction-to-sequence-to-sequence-learning-in-keras.html). It…

Ridvan Aydin Sibic
- 77
- 5
5
votes
0 answers
BatchNormalization layer in keras leads to oscillating validation accuracy
I am trying to use BatchNorm layers for a image classification task but I am having trouble with the keras implementation.When I run the same network with BatchNormalization layers I get better training accuracy and validation accuracy but during…

rob_m
- 321
- 1
- 9
5
votes
2 answers
Is there a relation between the number of LSTM units and the length of the sequence to be trained?
I have programmed keras neural network to train on sequences. Does choosing the LSTM units in keras depend on length of the sequence?

user239457
- 1,766
- 1
- 16
- 26
5
votes
1 answer
Python - LSTM based RNN required 3D input?
i am trying to build a deep learning network based on LSTM RNN here is what is tried
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation
from keras.layers import Embedding
from keras.layers import LSTM
import…

Hadeer El-Zayat
- 281
- 5
- 20
5
votes
1 answer
TypeError when trying to create a BLSTM network in Keras
I'm a bit new to Keras and deep learning. I'm currently trying to replicate this paper but when I'm compiling the second model (with the LSTMs) I get the following error:
"TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'"
The…

itroulli
- 2,044
- 1
- 10
- 21
5
votes
1 answer
When is Layer.build() invoked in source code in keras?
Every derived class of Layer class in keras has build() definition.
build() is place where we assign weights to the keras layer.
When is this function invoked internally? I am unable to find any piece of code which may be callling it
In __call_()…

abhishek jha
- 1,065
- 4
- 21
- 41
5
votes
1 answer
Is there is difference between the keras layers Masking() and Embedding(mask_zero =True)?
The documentation for the Embedding layer is here:
https://keras.io/layers/embeddings/
and the documentation for the Masking layer is here:
https://keras.io/layers/recurrent/
I cant find a difference there. Should one of the layers be prefered in…

Mimi Müller
- 416
- 8
- 25
5
votes
2 answers
How to specify filter in keras conv2d
I am trying to implement into my Keras model a conv2D layer that uses a specific Gaussian filter. I have code that makes the filter, although the existing Keras Conv2D does not have a parameter for the filter itself. Instead, there is a filters…

Alerra
- 1,479
- 11
- 25
5
votes
0 answers
How can I create a multihot embedding layer in Keras?
I have sequential data where each element is a vector as follows:
x_i = [ 0. , 0. , 0. , 0.03666667, 0. ,
0. , 0.95666667, 0. , 0. , 0. ,
0. , 0. , 0. …

Abdel Wahab Turkmani
- 109
- 7
5
votes
1 answer
keras: extracting weights using get_weights function
I would like to extract weights of 1d CNN layer, and understand how exactly the prediction values are computed. I am not able to re-produce the prediction values using the weights from get_weights() function.
In order to explain my understanding,…

FairyOnIce
- 2,526
- 7
- 27
- 48
5
votes
3 answers
Making neural network training reproducible using RStudio's Keras interface
I'm trying to make neural network training reproducible using RStudio's Keras interface. Setting a seed in the R script (set.seed(42)) doesn't seem to work. Is it possible to pass seeding as an argument to layer_dense()? I can choose RandomUniform…

SANBI samples
- 2,058
- 2
- 14
- 20
5
votes
1 answer
ValueError: Input 0 is incompatible with layer dense_6 in keras
I am trying to build a deep autoencoder by following this link, but I got this error:
ValueError: Input 0 is incompatible with layer dense_6: expected axis
-1 of input shape to have value 128 but got shape (None, 32)
The code:
input_img =…

matchifang
- 5,190
- 12
- 47
- 76
5
votes
2 answers
Keras - get weight of trained layer
I'm trying to get the values of a layer in a trained network. I can get the layer as a TensorFlow Tensor, but I'm unable to access its values in an array shape:
from keras.models import load_model
model = load_model('./model.h5')
layer_dict =…

Guig
- 9,891
- 7
- 64
- 126