1. Tensorflow 란?¶
tensorflow는 google에서 만든 딥러닝 프로그램을 쉽게 구현할 수 있는 라이브러리이다.
기본적인 언어를 지원하지만 python을 최우선으로 한다.
대부분의 편리한 기능들이 python library로만 구현되어 있다.
tenor란 딥러닝에서 데이터를 표현하는 방식을 뜻하고 flow는 흐름을 뜻한다. tensor의 이해가 매우 중요하다.
tensorflow의 연산은 dataflow graph로 이루어진다. 즉 텐서 형태의 데이터들이 딥러닝 모델을 구성하는 연산들의 그래프를 따라 흐르면서 연산한다고 보면 되겠다.
tensorflow는 가장 인기있는 딥러닝 라이브러리이고 딥러닝을 사용하는데 더욱 편리하게 해준다.
In [1]:
import tensorflow as tf
In [4]:
hello = tf.constant('Hello world')
sess = tf.Session()
print(sess.run(hello))
In [6]:
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0)
node3 = tf.add(node1, node2)
In [11]:
sess.run([node1, node2])
Out[11]:
In [12]:
sess.run(node3)
Out[12]:
In [14]:
# placeholder
# 그래프를 먼저 만들어 놓고 값들을 나중에 넣어준다.
# placeholder로 node를 만들어 준다.
a = tf.placeholder(tf.float32)
b = tf.placeholder(tf.float32)
adder_node = a + b
# feed_dict = {} 으로 값을 넘겨준다.
print(sess.run(adder_node, feed_dict={a:3.5, b:4.5}))
print(sess.run(adder_node, feed_dict={a:[1,3], b:[2,4]}))
tensor ranks, shapes and Type¶
s = 456 //ranks :1 , shape(1,1) type = int
s = [1,2]
s = [[1,2],[3,4]]
In [15]:
s1 = 442
s2 = [1,2]
s3 = [[1,2,3],[4,5,6],[5,6,7]]
In [31]:
print(sess.run(tf.shape(s1)))
print(sess.run(tf.shape(s2)))
print(sess.run(tf.shape(s3)))
In [33]:
print(sess.run(tf.rank(s1)))
print(sess.run(tf.rank(s2)))
print(sess.run(tf.rank(s3)))
'AI > Deep Learning' 카테고리의 다른 글
딥러닝: 04. Logistic Classification(로지스틱 회귀) (0) | 2019.07.30 |
---|---|
딥러닝: 03. 다중 선형 회귀(Multi Variable linear regression) (0) | 2019.07.30 |
딥러닝: 02. 경사하강법(Gradient descent algorithm) (0) | 2019.07.30 |
딥러닝 : 로지스틱 회귀 코딩 (0) | 2019.07.25 |
titanic : Machine Learning from Disaster - kaggle 연습 (0) | 2019.07.23 |
댓글