• Home
  • About
    • Jang photo

      Jang

      Jang's blog

    • Learn More
    • Email
    • Facebook
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

TensorFlow를 다뤄보자(inflearn)

09 Feb 2017

Reading time ~1 minute

Tensorflow

설치

일단 virtual-env 및 autoenv 를 설정해주자.

pip install tensorflow
pip install tensorflow-gpu # GPU 사용가능 시 속도를 더 빠르게 해줌.

첫 번째 프로그램

tensorflow를 설치 하고, 아래의 프로그램을 실행해보자.(HelloWorld 출력)

import tensorflow as tf

hello = tf.constant('Hello World!')

sess = tf.Session()

print (sess.run(hello))

나같은 경우엔 아래와 같은 에러가 떴는데,

...
Error importing tensorflow.  Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there.

구글링을 통해 아래와 같은 방법으로 해결하였다.
StackOverflow

출처:StackOverflow

!! note TensorFlow는 변수에 값을 저장하는 것이 아니라 operation 정보를 저장하고, 실행 중에 그 값이 결정되도록 한다.

예를 들어, c = a + b라고 하면 c에 a와 b를 더한 값이 들어가는 것이 아니라, 더하는 연산에 대한 정보가 들어가게 된다.

TensorFlow를 사용한 Linear Regression

Linear Regression의 cost function: cost
이 cost function을 최소화 하는 것이 목표이다.



tensorflowmachine-learninginflearn Share Tweet +1