### Why TensorFlow?
텐서플로는 오픈소스 기반으로 다른 라이브러리에 비해 2~4배 정도의 코드와 자료들이 있음.
상대적으로 접근이 쉬운 것이 장점.
### What is a Data Flow Graph?
노드 그래프 기반 오퍼레이션.
### Installing TensorFlow
1. python 설치
2. pip install tensoflow==1.5.0 // 아마 geforce 계열 gpu사용이 기본이겠지?
인텔의 경우 샌디브릿지부터 AVX를 지원함. 암드의 경우 재규어, 퓨마, 불도저 시리즈부터.
그 밑에 CPU는 텐서플로 1.5버전을 받아야함. // 회사 CPU가 고대 유물이라 1.5버전 받음.
// 추가 수정 : 회사에 텐서플로용 1000만원짜리 서버가 있었음. 이걸 학습자들끼리 공유하여 사용하기로 결정!
3. bazel ... // 컴파일러
4. Google search / Community help
### Check installation and version
1. $ python3
1 2 | import tensorflow as tf tf.__version__ |
>> '1.12.0'
### Hello TensorFlow!
1 2 3 | hello = tf.constant("Hello, TensorFlow!") sess = tf.Session() print(sess.run(hello)) |
1 2 3 | node1 = tf.constant(3.0, tf.float32) node2 = tf.constant(4.0) node3 = tf.add(node1, node2) |
1 2 | print("node1:", node1, "node2:", node2) print("node3:", node3) |
1 2 | node1: Tensor("Const_6:0", shape=(), dtype=float32) node2: Tensor("Const_7:0", shape=(), dtype=float32) node3: Tensor("Add:0", shape=(), dtype=float32) |
1 2 3 | sess = tf.Session() print("sess.run(node1, node2):", sess.run([node1, node2])) print("sess.run(node3): ", sess.run(node3)) |
1 2 | sess.run(node1, node2): [3.0, 4.0] sess.run(node3): 7.0 |
1 2 3 4 5 6 | a = tf.placeholder(tf.float32) b = tf.placeholder(tf.float32) adder_node = a + b print(sess.run(adder_node, feed_dict={a: 3, b: 4.5})) print(sess.run(adder_node, feed_dict={a: [1,3], b: [2,4]})) |
1 2 | 7.5 [3. 7.] // 아니 배열 연산이 가능하다고!!??? 스고이! 어썸! |
### Everything is Tensor
Tensor를 이해하면 ML, DL을 잘 활용하는 것이 가능.
Tensor는 기본적으로 Array이다.
### Tensor Ranks, Shapes, and Types
Ranks - 차원
- Scalar // 0차
- Vector // 1차
- Matrix // 2차
- 3-Tensor // 3차
- n-Tensor // n차
Shapes - element에 몇개가 들어있는지
ex) t = [[1,2,3], [4,5,6], [7,8,9]] => [3, 3] / [D0, D1] / 2-D
Types - tf.float32 를 가장 많이 사용. 다른 언어와 동일함.
### 참고
https://www.youtube.com/watch?v=-57Ne86Ia8w&index=3&list=PLlMkM4tgfjnLSOjrEJN31gZATbcj_MpUm // 영상을 토대로 글을 작성함
'AI - ML' 카테고리의 다른 글
ML lab 04-2: TensorFlow로 파일에서 데이타 읽어오기 (new) (0) | 2019.03.18 |
---|---|
ML lab 02 - TensorFlow로 간단한 linear regression을 구현 (new) (0) | 2019.02.18 |
ML lec 02 - Linear Regression의 Hypothesis 와 cost 설명 (0) | 2019.02.18 |
ML lec 01 - 기본적인 Machine Learning 의 용어와 개념 설명 (0) | 2019.02.15 |
Lec 00 - Machine/Deep learning 수업의 개요와 일정 (0) | 2019.02.15 |