TensorFlow 출력 인쇄 장 량 조작

804 단어 TensorFlow 기초
1.세 션 세 션 을 간단하게 사용 합 니 다.계산 이 끝나 면 세 션 을 닫 아야 합 니 다.
>>> hello = tf.constant('Hello TensorFlow')
>>> sess = tf.Session()
>>> print(sess.run(hello))
b'Hello TensorFlow'
>>> sess.run(hello)    #    print()    
b'Hello, TensorFlow!'
>>> a = tf.constant(1)
>>> b = tf.constant(2)
>>> print(sess.run(a+b))
3
>>> sess.close()

2、세 션 세 션 사용 후 자동 종료
>>> hello = tf.constant('Hello, TensorFlow!')
>>> hello = tf.constant('Hello TensorFlow')
>>> a = tf.constant(1)
>>> b = tf.constant(2)
>>> with tf.Session() as sess:
...     sess.run(hello)
...     sess.run(a+b)
...
b'Hello TensorFlow'
3

좋은 웹페이지 즐겨찾기