I am using Keras to build a Network. During the process, I need a layer, which takes an LSTM input, doing nothing, just output exactly the same as input. i.e. if each input record of LSTM is like [[A_t1, A_t2, A_t3, A_t4, A_t5, A_t6]], I am looking for a layer:
model.add(SomeIdentityLayer(x))
SomeIdentityLayer(x) will take [[A_t1, A_t2, A_t3, A_t4, A_t5, A_t6]]
as input and output [[A_t1, A_t2, A_t3, A_t4, A_t5, A_t6]]
. Is such layer/structure available in Keras? Thanks!
Just do a model. summary(). It will print all layers and their output shapes.
In a Keras layer, the input shape is generally the shape of the input data provided to the Keras model while training. The model cannot know the shape of the training data. The shape of other tensors(layers) is computed automatically.
Input() is used to instantiate a Keras tensor. A Keras tensor is a symbolic tensor-like object, which we augment with certain attributes that allow us to build a Keras model just by knowing the inputs and outputs of the model. shape: A shape tuple (integers), not including the batch size.
Actually, default call()
implementation in Layer
is identity, so you can just use:
model.add(Layer())
For a simpler operation like identity, you can just use a Lambda layer like:
model.add(Lambda(lambda x: x))
This will return an output exactly the same as your input.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With