I was wondering if there is any other way to write my own Keras layer instead of inheritance way as given in their documentation? My colleague is more comfortable in tensorflow and he gave me a tensorflow function that does the job of the layer. Do I necessarily have to rewrite it as Keras' inherited layer?
2 Answers
you can overwrite tensorflow classes and add you function as layer as colleague mentioned but Keras is just high level API to tensorflow and that layer can be called from keras.
Depends on what keras you are using. If you are using Keras (not tf Keras), then you have to inherit from Keras Layer. This behaviour is. One of the reason for this behaviour is Keras wants their framework to support multiple backend (although I have never seen people changing backend midway). Think of keras as a middleman and backend as the worker, and by using keras you are communicating with the middleman and then keras will relay it to the worker and hence you must use the language that the middleman understands.
Tensorflow 2.0 offers tf-keras as its high-level api. You can mix and match tensorflow functions and keras layers(only if you import it from tf.keras). This might be what you are looking for.