![](/img/trans.png)
[英]How to fix AttributeError: module 'tensorflow' has no attribute 'reset_default_graph'
[英]How do I solve reset_default_graph() error with tensorflow?
我正在尝试在 VS 代码中训练 model 并编写了以下代码(其中的一部分):
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")
...
output: raise RuntimeError('尝试使用封闭的 Session。') RuntimeError: 尝试使用封闭的 Session。
我不明白我做错了什么,有人可以帮忙吗?
您可以删除try
和except
块并仅提及 except 块中的以下行而不使用try
和except
,这应该有效。
modell.fit(trening, output, n_epoch=1000, batch_size=8, show_metric=True)
modell.save("modell.tflearn")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.