1
$\begingroup$

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?

$\endgroup$
0
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.