강의

멘토링

커뮤니티

Inflearn Community Q&A

lhr48846306's profile image
lhr48846306

asked

Deep Learning for Everyone - Basic Machine Learning and Deep Learning Course

TensorFlow installation and basic operations (new)

텐서플로우

Written on

·

553

0

텐서플로우 설치후, 강의에서 보여준 코드를 입력했는데 다음과 같이 오류가 떠요 ㅠ

In :

import tensorflow as tf

hello = tf.constant("Hello, TensorFlow!")

sess = tf.Session()

print(sess.run(hello))

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-77bcd9f617b4> in <module>
      1 import tensorflow as tf
      2 hello = tf.constant("Hello, TensorFlow!")
----> 3 sess = tf.Session()
      4 print(sess.run(hello))

AttributeError: module 'tensorflow' has no attribute 'Session'

어떻게 해야 할까요 ㅠ
딥러닝강화학습

Answer 2

5

텐서플로우가 1.0에서 2.0으로 업그레이드 되며 session이 사라졌다고 합니다.

참고 : https://eclipse360.tistory.com/40

1

텐서플로우 버전 2.0.0에서는 Session을 정의하고 run 해주는 과정이 생략되었다고 하네요. 아래와 같이 해주면 될 듯 합니다. 

hello = tf.constant("Hello, TensorFlow!")

tf.print(hello)

lhr48846306's profile image
lhr48846306

asked

Ask a question