在Tenforflow2.0版本上的问题调试

Traceback (most recent call last):
  File "freeze_model.py", line 59, in <module>
    main()
  File "freeze_model.py", line 54, in main
    frozen_graph = freeze_session(K.get_session(),  output_names=[out.op.name for out in prediction_model.outputs])
  File "freeze_model.py", line 26, in freeze_session
    session, input_graph_def, output_names, freeze_var_names)
  File "/home/jimchen/anaconda3/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 324, in new_func
    return func(*args, **kwargs)
  File "/home/jimchen/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/graph_util_impl.py", line 297, in convert_variables_to_constants
    source_op_name = get_input_name(node)
  File "/home/jimchen/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/graph_util_impl.py", line 254, in get_input_name
    raise ValueError("Tensor name '{0}' is invalid.".format(node.input[0]))
ValueError: Tensor name 'stem_bn/cond/ReadVariableOp/Switch:1' is invalid.

Solution:
    orig source code:
    frozen_graph = freeze_session(K.get_session(),  output_names=[out.op.name for out in prediction_model.outputs])
    modified code:
   output_names=[out.op.name for out in prediction_model.outputs]
   frozen_graph = freeze_session(K.get_session(), output_names )

 

posted @ 2020-09-22 23:06  jimchen1218  阅读(261)  评论(0编辑  收藏  举报