Open ThibaultDECO opened 4 months ago
Hi @ThibaultDECO , Thanks for report. I have reproduced the issue with nightly and attached gist for reference.
Hi @ThibaultDECO - thank you for flagging this. Would you be interested in contributing the fix? I believe just replacing len(x)
with len(ops.shape(x))
should work but you would have to confirm.
Otherwise we'll take this up.
Hi @grasskin I unfortunately do not have time to look at the issue atm
Just ran into something similar with the bidirectional layer type. Would this line here trigger this bug? The traceback I'm getting isn't super useful in this case so I'm just trying to figure out if I need to keep digging.
Did you disable traceback filtering to get the full traceback error? @evz
Yeah so, I turned off the traceback filtering and it is, indeed, related.
File "/home/eric/code/coursera/.venv/lib/python3.10/site-packages/tensorflow/python/framework/tenso
r.py", line 633, in __len__
raise TypeError(f"len is not well defined for a symbolic Tensor "
TypeError: Exception encountered when calling Bidirectional.call().
len is not well defined for a symbolic Tensor (states:0). Please call `x.shape` rather than `len(x)
` for shape information.
Arguments received by Bidirectional.call():
• sequences=tf.Tensor(shape=(1, None, 256), dtype=float32)
• initial_state=tf.Tensor(shape=(1, 2048), dtype=float32)
• mask=None
• training=None
The backdrop here is that I'm working through the Shakespeare RNN example from the Tensorflow docs and toying around with adding a bidirectional layer to the model. I'm not even really sure it makes sense as a choice for that particular problem. I'm mostly just interested in figuring out how these things work.
I wonder whether x.shape is best or ops.shape(...)
and then len(result)
.
I'm not sure about the details but I think the ops
namespace deals with symbolic tensors as it seems to be the case.
I also encountered this issue with bi directional RNN. Is the issue fixed?
I get the following error with keras:
len is not well defined for a symbolic Tensor. Please call 'x.shape' rather than 'len(x)' for shape information.
The issue seems to originate from this line.
Here is a gist where the error is reproduced.