【问题标题】:Error while loading a pretrained resnet model加载预训练的 resnet 模型时出错
【发布时间】:2019-07-09 05:22:43
【问题描述】:

我正在尝试在以下链接中加载预训练的 ResNet 模型 https://drive.google.com/open?id=1xkVK92XLZOgYlpaRpG_-WP0Elzg4ewpw

但它给出了 RuntimeError: The Session graph is empty。在调用 run() 之前向图中添加操作。

可能的问题是什么?

import tensorflow as tf
import tensorflow.contrib.slim as slim

# Let's load a previously saved meta graph in the default graph
# This function returns a Saver
saver = tf.train.import_meta_graph('model.ckpt-0.meta')

# We can now access the default graph where all our metadata has been loaded
graph = tf.get_default_graph()

with tf.Session(graph=tf.Graph()) as sess:

    saver.restore(sess, 'model.ckpt-0.data-00000-of-00001')
    print('Worked')

【问题讨论】:

    标签: tensorflow resnet pre-trained-model


    【解决方案1】:

    你必须有一个模型(Rough house),并且加载参数(Bed,家具)。现在你需要一个Rough house(操作,例如:tf.Variable(),tf.add(),tf.nn。 softmax_cross_entropy_with_logits())。

    【讨论】:

      【解决方案2】:
      with tf.Session() as sess:
      #  tf.saved_model.loader.load(sess, [tag_constants.TRAINING], export_dir)
      
        saver = tf.train.import_meta_graph('C://Users//hardi//tutorial//resnet//model.ckpt.meta')
      #  new_saver   = saver.restore(sess, tf.train.latest_checkpoint('C://Users//hardi//tutorial//resnet//'))
        saver.restore(sess, 'model.ckpt')
        graph = tf.get_default_graph()
        print('success')
      

      错误是将保护程序实例带入循环并使用“model.ckpt”而不是“model.ckpt-0.data-00000-of-00001”作为 V2 检查点 在这里找到解决方案https://github.com/tensorflow/models/issues/2676

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-06-09
        • 2018-10-16
        • 1970-01-01
        • 1970-01-01
        • 2021-01-12
        • 2021-04-05
        • 1970-01-01
        相关资源
        最近更新 更多