【问题标题】:Cannot restore Dropout using get_tensor_by_name无法使用 get_tensor_by_name 恢复 Dropout
【发布时间】:2020-02-04 15:45:16
【问题描述】:

我尝试保存和恢复一些张量。

在保存会话中:

...
self.abc = tf.reduce_sum(self.element_wise_product, 2, name="abc")
self.def= tf.nn.dropout(abc, self.dropout_keep[0], name="def")
... 

保存后尝试恢复会话

sess = tf.Session(config=config)
weight_saver.restore(sess, save_file)

pretrain_graph = tf.get_default_graph()
abc= pretrain_graph.get_tensor_by_name('abc:0')
def = pretrain_graph.get_tensor_by_name('def:0')

但我得到了错误:

“名称‘def:0’指的是一个不存在的张量。 图中不存在操作‘def’。”

请帮忙。

【问题讨论】:

    标签: tensorflow machine-learning tensor dropout


    【解决方案1】:

    问题在于tf.nn.dropout(abc, self.dropout_keep[0], name="def") 是一个 TensorFlow 操作,而不是图中可以恢复的节点。

    此外,我将恢复图中要执行的节点,例如 logits 节点,以便我可以获得模型的输出和 input 节点,以便我可以将数据倒入模型中.因此,我认为没有理由恢复 dropout 节点。

    【讨论】:

    • 感谢 Gorjan,我也对此表示怀疑。你能提出一个解决方案来恢复辍学吗?或者你认为节点就足够了,真的没有必要?
    猜你喜欢
    • 2020-04-02
    • 1970-01-01
    • 2017-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多