tensorflow: Working code broke after deploying to new installation. ValueError: When using `stateful=True` in a RNN, the batch size must be static. Found dynamic batch size: sequence.shape=(None, xx, xx)
Issue type
Bug
Have you reproduced the bug with TensorFlow Nightly?
Yes
Source
source
TensorFlow version
2.16.1
Custom code
No
OS platform and distribution
Ubuntu 22.04
Mobile device
No
Python version
3.10.12
Bazel version
No response
GCC/compiler version
No response
CUDA/cuDNN version
12.4
GPU model and memory
No response
Current behavior?
So the existing code broke, with this error
ValueError: When using stateful=True in a RNN, the batch size must be static. Found dynamic batch size: sequence.shape=(None, XX, XX),
but when changed to (XX, XX, XX) I get this, ValueError: Input 0 of layer “lstm” is incompatible with the layer: expected ndim=3, found ndim=4. Full shape received: (None, 1, XX, XX)
If static shape is passed, not sure why additional dimension is added. Need help in resolving this. I tried both the release version and nightly version. The issue persists
And also the input is 3D tensor produced by timeseries_dataset_from_array function. Is there any example on training stateful LSTM using these 3D tensors? Not sure if this is a bug really. I am stuck.
Standalone code to reproduce the issue
Dont have stand alone.
Relevant log output
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (2 by maintainers)
Try using the input layer instead of batch_input_shape.
InputLayer(batch_shape=(1,None,4))