Questions tagged [keras-layer]

1512 questions
6
votes
4 answers

Why not use Flatten followed by a Dense layer instead of TimeDistributed?

I am trying to understand the Keras layers better. I am working on a sequence to sequence model where I embed a sentence and pass it to a LSTM that returns sequences. Hereafter, I want to apply a Dense layer to each timestep (word) in the sentence…
6
votes
1 answer

How to merge multiple sequential models in Keras Python?

I'm building a model with multiple sequential models that I need to merge before training the dataset. It seems keras.engine.topology.Merge isn't supported on Keras 2.0 anymore. I tried keras.layers.Add and keras.layers.Concatenate and it doesn't…
K. K.
  • 552
  • 1
  • 11
  • 20
6
votes
2 answers

Keras Layer Concatenation

I'm trying to see how I can create a model in Keras with multiple Embedding Layers and other inputs. Here's how my model is structured(E=Embedding Layer, [....]=Input Layer): E E [V V V] \ | / \ | / Dense | Dense Here is my code so…
Light
  • 375
  • 4
  • 11
6
votes
3 answers

How to implement Merge from Keras.layers

I have been trying to merge the following sequential models but haven't been able to. Could somebody please point out my mistake, thank you. The code compiles while using"merge" but give the following error "TypeError: 'module' object is not…
Raj Dayal
  • 65
  • 1
  • 1
  • 4
6
votes
1 answer

Multiple Embedding layers for Keras Sequential model

I am using Keras (tensorflow backend) and am wondering how to add multiple Embedding layers into a Keras Sequential model. More specifically, I have several columns in my dataset which have categorical values and I have considered using one-hot…
Eric Broda
  • 6,701
  • 6
  • 48
  • 72
6
votes
5 answers

Extremely poor prediction: LSTM time-series

I tried to implement LSTM model for time-series prediction. Below is my trial code. This code runs without error. You can also try it without dependency. import numpy as np, pandas as pd, matplotlib.pyplot as plt from sklearn.preprocessing import…
Roman
  • 3,007
  • 8
  • 26
  • 54
6
votes
1 answer

Concatenation of Keras parallel layers changes wanted target shape

I'm a bit new to Keras and deep learning. I'm currently trying to replicate this paper but when I'm compiling the first model (without the LSTMs) I get the following error: "ValueError: Error when checking target: expected dense_3 to have shape…
itroulli
  • 2,044
  • 1
  • 10
  • 21
6
votes
1 answer

Does 1D Convolutional layer support variable sequence lengths?

I have a series of processed audio files I am using as input into a CNN using Keras. Does the Keras 1D Convolutional layer support variable sequence lengths? The Keras documentation makes this unclear. https://keras.io/layers/convolutional/ At the…
JME
  • 2,293
  • 9
  • 36
  • 56
6
votes
0 answers

Access target inside a custom layer in Keras

I am writing a custom layer in Keras and I wonder if there is a way to access the target values inside the layer. class Custom(Layer): def __init__(self, **kwargs): super(Custom, self).__init__(**kwargs) def build(self,…
DalekSupreme
  • 1,493
  • 3
  • 19
  • 32
6
votes
2 answers

element-wise multiplication with broadcasting in keras custom layer

I am creating a custom layer with weights that need to be multiplied by element-wise before activation. I can get it to work when the output and input is the same shape. The problem occurs when I have a first order array as input with a second order…
buckithed
  • 193
  • 1
  • 2
  • 11
6
votes
3 answers

Keras Concatenate TypeError: __init__() got multiple values for argument 'axis'

I am currently trying to recreate the Unet. At the "upconvolution" part where the outputs of two layers needs to be merged I got the mentioned error. (TypeError: init() got multiple values for argument 'axis') Keras Version: 2.0.6 Tensorflow-gpu:…
Midas.Inc
  • 1,730
  • 3
  • 13
  • 25
6
votes
1 answer

How to initialize a convolution layer with an arbitrary kernel in Keras?

I want to initialize the convolution layer by a specific kernel which is not defined in Keras. For instance, if I define the below function to initialize the kernel: def init_f(shape): ker=np.zeros((shape,shape)) …
6
votes
2 answers

Keras: What is the difference between layers.Input and layers.InputLayer?

When should I use Input and when should I use InputLayer? In the source code there is a description, but I am not sure what it means. InputLayer: Layer to be used as an entry point into a graph. It can either wrap an existing tensor (pass an…
Toke Faurby
  • 5,788
  • 9
  • 41
  • 62
6
votes
2 answers

What does Dense do?

What is the meaning of the two Dense in this…
K.SUP
  • 61
  • 1
  • 1
  • 3
6
votes
2 answers

skipping layer in backpropagation in keras

I am using Keras with tensorflow backend and I am curious whether it is possible to skip a layer during backpropagation but have it execute in the forward pass. So here is what I mean Lambda (lambda x: a(x)) I want to apply a to x in the forward…
DalekSupreme
  • 1,493
  • 3
  • 19
  • 32