I am trying to create a rather complex lambda-layer with many operations in keras. After I implemented it, I got a ValueError: No gradients provided for any variable
.
While I am using only keras operations to transform the data, (except for a constant I create using numpy which I later add onto a Tensor) I understand that there must be some operations which are not differentiable. Now I want to know how I can figure out which one it is, so I can find a workaround.
I don't want publish any code yet as it is part of a competition and I want to figure this out on my own. If it is difficult to understand my problem because of that, please let me know. I can however give a list of all the functions I am using:
from tensorflow.keras import backend as K
from tensorflow.python.keras.layers import Lambda
...
def my_lambda_function(x):
# uses:
K.batch_dot
K.cast
K.clip
K.concatenate
K.one_hot
K.reshape
K.sum
K.tile # only applied to a constant created in numpy
...
# using the function in a model like this:
my_lambda_layer = Lambda(my_lambda_function)
result_tensor = my_lambda_layer(some_input)
I think K.one_hot could be problematic, but I want a way to know this for sure before I try making it differentiable