I have a tf.keras lstm model that I trained on Google Colab and I want to load it on my laptop so I can run it to do inference.
I created a Python virtual environment on my laptop with the same versions of Tensorflow/Keras as Google Colab (2.15) and the same version of Python (3.10).
Despite this, when I load the model I get the following errors:
2024-07-03 15:01:12.725137: W tensorflow/core/common_runtime/graph_constructor.cc:840] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 42 outputs. Output shapes may be inaccurate.
2024-07-03 15:01:13.713773: W tensorflow/core/common_runtime/graph_constructor.cc:840] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 42 outputs. Output shapes may be inaccurate.
2024-07-03 15:01:14.703037: W tensorflow/core/common_runtime/graph_constructor.cc:840] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 42 outputs. Output shapes may be inaccurate.
2024-07-03 15:01:14.887920: W tensorflow/core/common_runtime/graph_constructor.cc:840] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 42 outputs. Output shapes may be inaccurate.
2024-07-03 15:01:15.375012: W tensorflow/core/common_runtime/graph_constructor.cc:840] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 42 outputs. Output shapes may be inaccurate.
2024-07-03 15:01:15.841333: W tensorflow/core/common_runtime/graph_constructor.cc:840] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 42 outputs. Output shapes may be inaccurate.
2024-07-03 15:01:15.884074: W tensorflow/core/common_runtime/graph_constructor.cc:840] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 42 outputs. Output shapes may be inaccurate.
2024-07-03 15:01:17.601834: W tensorflow/core/common_runtime/graph_constructor.cc:840] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 42 outputs. Output shapes may be inaccurate.
2024-07-03 15:01:17.638458: W tensorflow/core/common_runtime/graph_constructor.cc:840] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 42 outputs. Output shapes may be inaccurate.
2024-07-03 15:01:18.121723: W tensorflow/core/common_runtime/graph_constructor.cc:840] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 42 outputs. Output shapes may be inaccurate.
The model is a tf.keras.Sequential
model saved with its save
method and loaded with the tf.keras.models.load_model
method.
Looking for this problem I saw that it is mainly due to differences in the versions of tensorflow/keras between the environment where the model is saved and the one where it is loaded, but this is not my case. The only difference is the operating system (Linux vs Windows). I also found a thread indicating to add compile=False
in the tf.keras.models.load_model
method, but this does not change anything in my case.
Do you have any suggestions on how to solve this problem? I would like to have a model that can be ported to different devices, as long as the same Python virtual environment is used.