gpt4 book ai didi

python-3.x - 名称错误 : name 'sess' is not defined

转载 作者:行者123 更新时间:2023-12-01 11:19:05 29 4
gpt4 key购买 nike

我在 tensorflow 下运行 python 程序。当我输入sess.run()时,命令行提示我NameError: name 'sess' is not defined

print(sess.run(W_conv1))
Traceback (most recent call last):

File "<ipython-input-17-cf7d3892efbb>", line 1, in <module>
print(sess.run(W_conv1))

NameError: name 'sess' is not defined

最佳答案

您必须定义sess。在访问它之前放置此行。

sess = tf.Session()

甚至您可以使用 with 语句:

with tf.Session() as sess:

#Do something with sess
print(sess.run(W_conv1))

关于python-3.x - 名称错误 : name 'sess' is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46279290/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com