Data Science Asked on December 24, 2020
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?
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.
Answered by P K on December 24, 2020
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.
Answered by Yohanes Alfredo on December 24, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP