【问题标题】:How do I solve reset_default_graph() error with tensorflow?如何使用 tensorflow 解决 reset_default_graph() 错误?
【发布时间】:2020-12-27 12:42:26
【问题描述】:

我正在尝试用 VS 代码训练模型并编写了这段代码(其中的一部分):

import tensorflow as tf
import tflearn'
....
tf.reset_default_graph()

net = tflearn.input_data(shape=[None, len(trening[0])]) 
net = tflearn.fully_connected(net, 8) 
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, len(output[0]), activation="softmax") 
net = tflearn.regression(net)

modell = tflearn.DNN(net)

try: 
    modell.load("modell.tflearn")
except:
    modell.fit(trening, output, n_epoch=1000, batch_size=8, show_metric=True) 
    modell.save("modell.tflearn")
...

输出:raise RuntimeError('尝试使用已关闭的会话。') RuntimeError: 尝试使用已关闭的会话。

我不明白我做错了什么,有人可以帮忙吗?

【问题讨论】:

    标签: python python-3.x tensorflow artificial-intelligence tflearn


    【解决方案1】:

    您可以删除 tryexcept 块,并仅提及除块中的以下行,而没有 tryexcept,这应该可以。

    modell.fit(trening, output, n_epoch=1000, batch_size=8, show_metric=True) 
    modell.save("modell.tflearn")
    

    【讨论】:

      猜你喜欢
      • 2021-09-28
      • 1970-01-01
      • 2021-02-27
      • 1970-01-01
      • 2019-07-27
      • 1970-01-01
      • 2021-09-02
      • 1970-01-01
      • 2021-10-28
      相关资源
      最近更新 更多