반응형



텐서플로우 2.0에서 Session 사용 방법만 바뀐지 알았는데  디폴트로 자동으로 생성되던 Graph가 사라졌나봅니다. 

Graph를 따로 생성해줘야 하는군요. 



예전에 질문에 답했던 내용인데 포스트로 정리해봅니다.  


import tensorflow as tf

g = tf.Graph()
with g.as_default():  
hello=tf.constant('Hello World!')

sess = tf.compat.v1.Session(graph=g)
print(sess.run(hello))




import tensorflow as tf


g = tf.Graph()
with g.as_default():  
a = tf.constant(3, name="a")
b = tf.constant(2, name="b")
c = tf.constant(1, name="c")

d = a * b
e = d + c

sess = tf.compat.v1.Session(graph=g)
print(sess.run(e))




최초 작성 2019. 11. 9




반응형

문제 발생시 지나치지 마시고 댓글 남겨주시면 가능한 빨리 답장드립니다.

도움이 되셨다면 토스아이디로 후원해주세요.
https://toss.me/momo2024


제가 쓴 책도 한번 검토해보세요 ^^

+ Recent posts