I have implemented a Keras Custom Layer in which I call a custom function inside the call method, the issue is when Keras is constructing the model, it is calling my custom layers call function with non - concrete data( maybe to check for shapes or error, don't know the exact reason ) with the shape ( None, 64, 64, 1 ) in which None specifies the batch which is unknown yet, and ( 64, 64, 1 ) is the shape of each image I am feeding to the model. Now, since these images are not concrete as the fit method is not called yet, the custom function I have defined is throwing the error relating to the NULL array passed. My question is:-

1.) Is there any way to tell Keras not to call this custom function if not at runtime?


2.) To not let Keras call the custom layer call method before the fit method is called?

Questing Addition:- If while constructing the model, Non-Concrete Data is passed, how come other layers( eg Dense ) don't throw up errors since even they are performing an operation( eg. matmul ) on data which doesn't actually exist?


Your Answer

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

Browse other questions tagged or ask your own question.