Skip to content

problem saving stateful LSTM model #20

@queniesun

Description

@queniesun

Saving TF2 model to frozen graph worked for me, thank you! However, when I trained my LSTM model with stateful=True, it failed:

frozen_func = convert_variables_to_constants_v2(full_model, lower_control_flow=False)

File ".../lib/python3.7/site-packages/tensorflow/python/framework/convert_to_constants.py", line 1075, in convert_variables_to_constants_v2
converted_input_indices)
File ".../lib/python3.7/site-packages/tensorflow/python/framework/convert_to_constants.py", line 1001, in _construct_concrete_function
new_output_names)
File ".../lib/python3.7/site-packages/tensorflow/python/eager/wrap_function.py", line 650, in function_from_graph_def
wrapped_import = wrap_function(_imports_graph_def, [])
File ".../lib/python3.7/site-packages/tensorflow/python/eager/wrap_function.py", line 628, in wrap_function
collections={}),
File ".../lib/python3.7/site-packages/tensorflow/python/framework/func_graph.py", line 986, in func_graph_from_py_func
func_outputs = python_func(*func_args, **func_kwargs)
File ".../lib/python3.7/site-packages/tensorflow/python/eager/wrap_function.py", line 87, in call
return self.call_with_variable_creator_scope(self._fn)(*args, **kwargs)
File ".../lib/python3.7/site-packages/tensorflow/python/eager/wrap_function.py", line 93, in wrapped
return fn(*args, **kwargs)
File ".../lib/python3.7/site-packages/tensorflow/python/eager/wrap_function.py", line 648, in _imports_graph_def
importer.import_graph_def(graph_def, name="")
File "/.../lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File ".../lib/python3.7/site-packages/tensorflow/python/framework/importer.py", line 405, in import_graph_def
producer_op_list=producer_op_list)
File ".../lib/python3.7/site-packages/tensorflow/python/framework/importer.py", line 501, in _import_graph_def_internal
raise ValueError(str(e))
ValueError: Input 0 of node sequential/lstm/AssignVariableOp was passed float from sequential/lstm/Read/ReadVariableOp/resource:0 incompatible with expected resource.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions