Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running export_larq_model.py #3

Closed
nathankopp opened this issue Mar 24, 2021 · 2 comments
Closed

Error running export_larq_model.py #3

nathankopp opened this issue Mar 24, 2021 · 2 comments

Comments

@nathankopp
Copy link

I've trained QuickYOLOv2 on a custom dataset and now I'm trying to convert it to LCE/TFLite. Unfortunately, when I run python export_larq_model.py, I get the following error:

ValueError: Input 0 of node model_1/batch_normalization_22/AssignNewValue was passed float from model_1/batch_normalization_22/FusedBatchNormV3/ReadVariableOp/resource:0 incompatible with expected resource.

Here's the full stack trace:

Traceback (most recent call last):
  File "C:\Users\x\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\framework\importer.py", line 496, in _import_graph_def_internal
    results = c_api.TF_GraphImportGraphDefWithResults(
tensorflow.python.framework.errors_impl.InvalidArgumentError: Input 0 of node model_1/batch_normalization_22/AssignNewValue was passed float from model_1/batch_normalization_22/FusedBatchNormV3/ReadVariableOp/resource:0 incompatible with expected resource.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "export_larq_model.py", line 124, in <module>
    flatbuffer_bytes = lce.convert_keras_model(yolo)
  File "C:\Users\x\AppData\Local\Programs\Python\Python38\lib\site-packages\larq_compute_engine\mlir\python\converter.py", line 118, in convert_keras_model
    frozen_func = convert_variables_to_constants_v2(func, lower_control_flow=False)
  File "C:\Users\x\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\framework\convert_to_constants.py", line 1076, in convert_variables_to_constants_v2
    return _construct_concrete_function(func, output_graph_def,
  File "C:\Users\x\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\framework\convert_to_constants.py", line 1001, in _construct_concrete_function
    new_func = wrap_function.function_from_graph_def(output_graph_def,
  File "C:\Users\x\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\eager\wrap_function.py", line 650, in function_from_graph_def
    wrapped_import = wrap_function(_imports_graph_def, [])
  File "C:\Users\x\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\eager\wrap_function.py", line 621, in wrap_function
    func_graph.func_graph_from_py_func(
  File "C:\Users\x\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\framework\func_graph.py", line 990, in func_graph_from_py_func
    func_outputs = python_func(*func_args, **func_kwargs)
  File "C:\Users\x\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\eager\wrap_function.py", line 87, in __call__
    return self.call_with_variable_creator_scope(self._fn)(*args, **kwargs)
  File "C:\Users\x\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\eager\wrap_function.py", line 93, in wrapped
    return fn(*args, **kwargs)
  File "C:\Users\x\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\eager\wrap_function.py", line 648, in _imports_graph_def
    importer.import_graph_def(graph_def, name="")
  File "C:\Users\x\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\util\deprecation.py", line 538, in new_func
    return func(*args, **kwargs)
  File "C:\Users\x\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\framework\importer.py", line 400, in import_graph_def
    return _import_graph_def_internal(
  File "C:\Users\x\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\framework\importer.py", line 501, in _import_graph_def_internal
    raise ValueError(str(e))
ValueError: Input 0 of node model_1/batch_normalization_22/AssignNewValue was passed float from model_1/batch_normalization_22/FusedBatchNormV3/ReadVariableOp/resource:0 incompatible with expected resource.
@tehtea
Copy link
Owner

tehtea commented Mar 29, 2021

As for this issue, I wasn't able to replicate it locally... Will try again on Google Colab. These are your environment settings right?

quickyolov2 model
CUDA 11.2
CUDNN 8.1.1.33
Tensorflow 2.4.1
Larq 0.11.2
LCE 0.5.0

@nathankopp
Copy link
Author

Yes, those are my environment settings. I have found a solution. Larq requires Tensorflow 2.3.0 and does not work properly with version 2.4.1.

Using pip install tensorflow==2.3.0 solved my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants