Exception encountered while importing 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)
Get exception in this line:
tf.import_ graph_ def(graph_ def)
ValueError: Input 0 of node import/save/Assign was passed float from import/beta1_ power:0 incompatible with expected float_ ref.
The solution: make sure your_ The file format is correct (similar to this), and try to_ graph_ Set some values in the ‘name’ parameter of def() to try to override the default value of ‘import’, as follows:
import tensorflow as tf
from tensorflow.python.platform import gfile
model_path="/tmp/frozen/dcgan.pb"
# read graph definition
f = gfile.FastGFile(model_path, "rb")
gd = graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
# fix nodes
for node in graph_def.node:
if node.op == 'RefSwitch':
node.op = 'Switch'
for index in xrange(len(node.input)):
if 'moving_' in node.input[index]:
node.input[index] = node.input[index] + '/read'
elif node.op == 'AssignSub':
node.op = 'Sub'
if 'use_locking' in node.attr: del node.attr['use_locking']
# import graph into session
tf.import_graph_def(graph_def, name='')
tf.train.write_graph(graph_def, './', 'good_frozen.pb', as_text=False)
tf.train.write_graph(graph_def, './', 'good_frozen.pbtxt', as_text=True)
Read More:
- [Solved] Vite Bulk Import import.meta.glob Error: ERR_ABORTED 403 (Forbidden)
- [Solved] node Error: SyntaxError: Cannot use import statement outside a module
- C# Error: Import “google/protobuf/timestamp.proto“ was not found or had errors. [How to Solve]
- Keras-nightly Import package Error: cannot import name ‘Adam‘ from ‘keras.optimizers‘
- Echars 5.0 Import Error: “export ‘default’ (imported as ‘echarts’) was not found in ‘echarts’
- [Solved] Eslint error: /xxx/components/xxx import should occur after import of /xxx/utils/xxx
- VScode integrate terminal input node error [How to Solve]
- How to Solve Import antd Error: Module build failed
- [Solved] React import the Path of Image error: cannot find mouse ‘.‘
- Uncaught SyntaxError: Cannot use import statement outside a module
- Keras Concatenate error: Layer concatenate_1 was called with an input that isn’t a symbolic tensor…
- How to Solve ImportError: cannot import name gof
- [Solved] Parsing error: The keyword ‘import‘ is reserved
- Celery Error: Did you remember to import the module containing this task?
- [Solved] Import gensim Error: RuntimeError: Cython extensions are unavailable.
- [Solved] HTML_Uncaught SyntaxError: Cannot use import statement outside a module
- Attempted import error: ‘mobx-react‘ does not contain a default export (imported as ‘observer‘).
- Unable to import maven project: See logs for details [Solved]
- Solution: from. Import ft2font importerror: DLL load failed: the specified module cannot be found
- [Solved] MXNet Error: ImportError: cannot import name _LIB