Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ValueError: Input 0 of node incompatible with expected float_ref.**

I'm getting below exception while trying to import my optimized frozen graph.

# read pb into graph_def
with tf.gfile.GFile(pb_file, "rb") as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())

# import graph_def
with tf.Graph().as_default() as graph:
    tf.import_graph_def(graph_def)

Getting the exception in this line:

tf.import_graph_def(graph_def)

Traceback (most recent call last): File
"/home/automator/PycharmProjects/tensorflow/venv/lib/python3.5/site-
packages/tensorflow/python/framework/importer.py", line 489, in
import_graph_def graph._c_graph, serialized, options) # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: Input 0 of node
import/final_retrain_ops/Wx_plus_b/weights_quant/AssignMinLast was
passed float from
import/final_retrain_ops/Wx_plus_b/weights_quant/min:0 incompatible
with expected float_ref. During handling of the above exception, another exception occurred: Traceback (most recent call last):
File "/snap/pycharm-community/64/helpers/pydev/pydevd.py", line 1664, in main() File "/snap/pycharm-community/64/helpers/pydev/pydevd.py", line 1658, in
main globals = debugger.run(setup['file'], None, None, is_module) File "/snap/pycharm-community/64/helpers/pydev/pydevd.py", line 1068, in run pydev_imports.execfile(file, globals, locals) # execute the script File
"/snap/pycharm-community/64/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/automator/PycharmProjects/tensorflow/tfliteme.py", line 389,
in printTensors("/home/automator/Desktop/cervix/optimized_model.pb")
File "/home/automator/PycharmProjects/tensorflow/tfliteme.py", line
374, in printTensors tf.import_graph_def(graph_def) File "/home/automator/PycharmProjects/tensorflow/venv/lib/python3.5/site-
packages/tensorflow/python/util/deprecation.py", line 432, in
new_func return func(*args, **kwargs) File "/home/automator/PycharmProjects/tensorflow/venv/lib/python3.5/site-
packages/tensorflow/python/framework/importer.py", line 493, in
import_graph_def raise ValueError(str(e)) ValueError: Input 0 of node import/final_retrain_ops/Wx_plus_b/weights_quant/AssignMinLast was
passed float from
import/final_retrain_ops/Wx_plus_b/weights_quant/min:0 incompatible
with

expected float_ref.

like image 341
Nael Marwan Avatar asked Jun 28 '18 13:06

Nael Marwan


1 Answers

Make sure your pb_file is in the right format (something like this) and also try to have some value in the 'name' parameter of import_graph_def() to try and override the "import" default value, like so:

# read pb into graph_def
with tf.gfile.GFile(pb_file, "rb") as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())

# import graph_def
with tf.Graph().as_default() as graph:
    tf.import_graph_def(graph_def, name='') 
like image 163
LemonPy Avatar answered Sep 30 '22 02:09

LemonPy