keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
62k stars 19.48k forks source link

Step by step method to implement a custom layer in keras with 2D /3D tensor as input #11895

Closed sandeeppandey456 closed 3 years ago

sandeeppandey456 commented 5 years ago

I am trying to implement a layer in keras which takes a 2D/3D tensor as input, perform some tensor transformations and gives a 2D/3D tensor as output. The output size is to be given as the input too. There will be trainable weights in the layer too. Please help

ParikhKadam commented 5 years ago

@sandeeppandey456 You can take a look at the layers folder in my project. They are purely implemented in Keras. https://github.com/ParikhKadam/bidaf-keras

Most of these layers work on 3D outputs. I think the best code for you will be this: https://github.com/ParikhKadam/bidaf-keras/blob/master/bidaf/layers/similarity_layer.py