Tensor Flow의 기본 변수및 함수 설명입니다.
123456789101112131415161718192021222324 # 텐서플로우의 기본적인 구성을 익힙니다.import tensorflow as tf# tf.constant: 말 그대로 상수입니다.hello = tf.constant('Hello, TensorFlow!')print(hello)a = tf.constant(10)b = tf.constant(32)c = tf.add(a, b) # a + b 로도 쓸 수 있음print(c)# 위에서 변수와 수식들을 정의했지만, 실행이 정의한 시점에서 실행되는 것은 아닙니다.# 다음처럼 Session 객제와 run 메소드를 사용할 때 계산이 됩니다.# 따라서 모델을 구성하는 것과, 실행하는 것을 분리하여 프로그램을 깔끔하게 작성할 수 있습니다.# 그래프를 실행할 세션을 구성합니다.sess = tf.Session()# sess.run: 설정한 텐서 그래프(변수나 수식 등등)를 실행합니다.print(sess.run(hello))print(sess.run([a, b, c]))# 세션을 닫습니다.sess.close()cs
'Deep Learning > Tensor Flow' 카테고리의 다른 글
Tensor Flow Code 분석 - Neural Network (0) | 2017.08.28 |
---|