Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NameError: name 'sess' is not defined

I am running python program under tensorflow. When I input sess.run(),the command line prompt me that 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
like image 392
Light Avatar asked Dec 03 '25 23:12

Light


1 Answers

You have to define sess. Put this line before accessing it.

sess = tf.Session()

or even you could use a with statement:

with tf.Session() as sess:

    #Do something with sess
    print(sess.run(W_conv1))
like image 160
Alber8295 Avatar answered Dec 05 '25 19:12

Alber8295