Questions tagged [keras-layer]

1512 questions
36
votes
2 answers

TimeDistributed(Dense) vs Dense in Keras - Same number of parameters

I'm building a model that converts a string to another string using recurrent layers (GRUs). I have tried both a Dense and a TimeDistributed(Dense) layer as the last-but-one layer, but I don't understand the difference between the two when using…
34
votes
3 answers

How does the Flatten layer work in Keras?

I am using the TensorFlow backend. I am applying a convolution, max-pooling, flatten and a dense layer sequentially. The convolution requires a 3D input (height, width, color_channels_depth). After the convolution, this becomes (height, width,…
ssg
  • 425
  • 1
  • 5
  • 7
32
votes
7 answers

ImportError: cannot import name '_obtain_input_shape' from keras

In Keras, I'm trying to import _obtain_input_shape as follows: from keras.applications.imagenet_utils import _obtain_input_shape However, I get the following error: ImportError: cannot import name '_obtain_input_shape' The reason I'm trying to…
Tshilidzi Mudau
  • 7,373
  • 6
  • 36
  • 49
31
votes
4 answers

How to Implement the Conv1DTranspose in keras?

I Know there is the Conv2DTranspose in keras which can be used in Image. We need to use it in NLP, so the 1D deconvolution is needed. How do we implement the Conv1DTranspose in keras?
Huo
  • 798
  • 3
  • 12
  • 22
31
votes
9 answers

Keras verbose training progress bar writing a new line on each batch issue

running a Dense feed-forward neural net in Keras. there are class_weights for two outputs, and sample_weights for a third output. fore some reason it prints the progress verbose display for each batch calculated, and not updating the print on the…
Natanel Davidovits
  • 331
  • 1
  • 3
  • 6
30
votes
4 answers

Is there any way to get variable importance with Keras?

I am looking for a proper or best way to get variable importance in a Neural Network created with Keras. The way I currently do it is I just take the weights (not the biases) of the variables in the first layer with the assumption that more…
user1367204
  • 4,549
  • 10
  • 49
  • 78
27
votes
3 answers

Keras: find out the number of layers

Is there a way to get the number of layers (not parameters) in a Keras model? model.summary() is very informative, but it is not straightforward to get the number of layers from it.
user673592
  • 2,090
  • 1
  • 22
  • 37
26
votes
5 answers

How to convert predicted sequence back to text in keras?

I have a sequence to sequence learning model which works fine and able to predict some outputs. The problem is I have no idea how to convert the output back to text sequence. This is my code. from keras.preprocessing.text import…
Eka
  • 14,170
  • 38
  • 128
  • 212
25
votes
6 answers

Keras retrieve value of node before activation function

Imagine a fully-connected neural network with its last two layers of the following structure: [Dense] units = 612 activation = softplus [Dense] units = 1 activation = sigmoid The output value of the net is 1, but I'd like to know…
johk95
  • 873
  • 10
  • 28
25
votes
2 answers

How to have parallel convolutional layers in keras?

I am a little new to neural networks and keras. I have some images with size 6*7 and the size of the filter is 15. I want to have several filters and train a convolutional layer separately on each and then combine them. I have looked at one example…
ida
  • 1,011
  • 1
  • 9
  • 17
24
votes
1 answer

How to get word vectors from Keras Embedding Layer

I'm currently working with a Keras model which has a embedding layer as first layer. In order to visualize the relationships and similarity of words between each other I need a function that returns the mapping of words and vectors of every element…
philszalay
  • 423
  • 1
  • 3
  • 9
24
votes
1 answer

Backward propagation in Keras?

can anyone tell me how is backpropagation done in Keras? I read that it is really easy in Torch and complex in Caffe, but I can't find anything about doing it with Keras. I am implementing my own layers in Keras (A very beginner) and would like to…
Tassou
  • 439
  • 1
  • 5
  • 16
24
votes
1 answer

Difference between Conv2D and Convolution2D in Keras

There is already an answer wrt to Tensorflow. But the problem is that In my IDE Conv2D is a class while Convolution2D is a variable?
22
votes
5 answers

Can someone explain to me the difference between activation and recurrent activation arguments passed in initialising keras lstm layer?

Can someone explain to me the difference between activation and recurrent activation arguments passed in initialising keras lstm layer? According to my understanding LSTM has 4 layers. Please explain what are th e default activation functions of…
Mayank Uniyal
  • 221
  • 1
  • 2
  • 4
21
votes
6 answers

Negative dimension size caused by subtracting 3 from 1 for 'conv2d_2/convolution'

I got this error message when declaring the input layer in Keras. ValueError: Negative dimension size caused by subtracting 3 from 1 for 'conv2d_2/convolution' (op: 'Conv2D') with input shapes: [?,1,28,28], [3,3,28,32]. My code is like…
Nurdin
  • 23,382
  • 43
  • 130
  • 308