• 카테고리

    질문 & 답변
  • 세부 분야

    딥러닝 · 머신러닝

  • 해결 여부

    미해결

텐서플로우

20.08.11 16:33 작성 조회수 264

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'

어떻게 해야 할까요 ㅠ

답변 2

·

답변을 작성해보세요.

5

YeSG님의 프로필

YeSG

2020.09.16

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

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

1

디리님의 프로필

디리

2022.02.06

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

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

tf.print(hello)