I have a trained LSTM model. I would like to calculate the Jacobian matrix of the output w.r.t input. I have written the following code:
data = pd.read_excel('filename')
a = data[:20] #shape is (20,5)
b = data[50:70] #shape is (20,5)
A = [a,b] #shape is (2,20,5)
At = tf.convert_to_tensor(A, np.float32)
with tf.GradientTape(persistent=True,watch_accessed_variables=True) as tape:
tape.watch(At)
y1 = model(At)
jacobian=tape.jacobian(y1,At)
I got the desired output but I am getting some warnings which I cannot understand. If its for one time that is ok to let them be. But I need to calculate the Jacobian matrix in a for loop which runs over 1000 times. So these warnings are appearing in each iteration of the for loop.
WARNING:tensorflow:Entity <function pfor.<locals>.f at 0x000002A6E0129CA8> could not be transformed
and will be executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the
verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause:
converting <function pfor.<locals>.f at 0x000002A6E0129CA8>: AssertionError: Bad argument number for
Name: 3, expecting 4
WARNING: Entity <function pfor.<locals>.f at 0x000002A6E0129CA8> could not be transformed and will be
executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the verbosity to
10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: converting
<function pfor.<locals>.f at 0x000002A6E0129CA8>: AssertionError: Bad argument number for Name: 3,
expecting 4
These are the two warnings that appear continuously during the for loop implementation. Can anyone help me out with either correcting my code or give me a trick to avoid these warnings?
Thank you :)