由于AssignVariableOp,使用tensorflow加载冻结图形时出错

由于AssignVariableOp,使用tensorflow加载冻结图形时出错,tensorflow,Tensorflow,我正在尝试冻结最初使用tensorflow 1.12.0创建的第三方模型检查点 然后把它转换成pb图,这样我就可以在不同的平台上使用它了 这是我冻结模型时遵循的指南 我遇到了以下错误 节点…/AssignVariableOp的输入0是从…/conv1d/queue:0传递的,与预期的资源不兼容 因为我没有自己创建模型,所以我不能对模型的架构进行太多修改。 我可以通过预先培训的检查点来解决这个问题吗? 我在互联网上看到过关于AssignVariableOp是否可以冻结的矛盾信息 我的当前设置:

我正在尝试冻结最初使用tensorflow 1.12.0创建的第三方模型检查点 然后把它转换成pb图,这样我就可以在不同的平台上使用它了

这是我冻结模型时遵循的指南

我遇到了以下错误

节点…/AssignVariableOp的输入0是从…/conv1d/queue:0传递的,与预期的资源不兼容

因为我没有自己创建模型,所以我不能对模型的架构进行太多修改。 我可以通过预先培训的检查点来解决这个问题吗? 我在互联网上看到过关于AssignVariableOp是否可以冻结的矛盾信息

我的当前设置:

  • Tensorflow 1.14.0
  • Windows10Pro
这是我尝试过但没有解决的问题:

  • 将tensorflow升级到1.15.0版或最新的2.x版

  • 根据此步骤冻结模型之前,将学习阶段设置为0

  • 使用英特尔分析公司版本的convert_variables_to_constants for this

# We start a session using a temporary fresh Graph
with tf.Session(graph=tf.Graph()) as sess:
    # We import the meta graph in the current default Graph
    saver = tf.train.import_meta_graph(input_checkpoint + '.meta', clear_devices=clear_devices)
    
    # We restore the weights
    saver.restore(sess, input_checkpoint)

    output_node_names = [<my list of output node I need>]

    # We use a built-in TF helper to export variables to constants
    output_graph_def = tf.graph_util.convert_variables_to_constants(
        sess, # The session is used to retrieve the weights
        tf.get_default_graph().as_graph_def(), # The graph_def is used to retrieve the nodes 
        output_node_names # The output node names are used to select the usefull nodes
    ) 

    # Finally we serialize and dump the output graph to the filesystem
    with tf.gfile.GFile(output_graph, "wb") as f:
        f.write(output_graph_def.SerializeToString())
with tf.io.gfile.GFile(pb_path, "rb") as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())

with tf.Graph().as_default() as graph:
    # The name var will prefix every op/nodes in your graph
    # Since we load everything in a new graph, this is not needed
    tf.import_graph_def(graph_def, name='')