SlideShare une entreprise Scribd logo
1  sur  99
Télécharger pour lire hors ligne
Introduction to
Python and TensorFlow
Contacts
• Haesun Park
• email : haesunrpark@gmail.com
• facebook : facebook.com/haesunrpark
• blog : tensorflow.blog
2
Book
• 텐서플로 첫걸음
• First Contact with TensorFlow, Jordie
Torres.
• 온라인 : tensorflow.blog/2016/04/28/first-
contact-with-tensorflow/
• Yes24 : yes24.com/24/goods/30547754
3
Outlook
• Part 1: 파이썬과 텐서플로우 소개
• Part 2: 회귀 분석과 로지스틱 회귀
• Part 3: 뉴럴 네트워크 알고리즘
• Part 4: 콘볼루션 뉴럴 네트워크
4
머신 러닝 소개
5
머신 러닝이란
“머신 러닝 또는 기계 학습은 인공 지능의 한 분야로, 컴퓨터가 학습할 수
있도록 하는 알고리즘과 기술을 개발하는 분야를 말한다.” - 위키피디아
“Field of study that gives computers the ability to learn without being
explicitly programmed.” - Arthur Samuel, 1959
6
AI ⊃ 머신러닝 ⊃ 딥러닝
• 딥러닝이란 인공신경망(Artificial Neural Network) 알고리즘을 사용한 머
신러닝의 한 분야이다.
7
머신 러닝 역사
8
ImageNet Challenge
9
2016년 2.99%
연구 분야
10
머신 러닝 분류
• 감독 여부나 주어지는 정보에 따라
• 지도 학습(supervised learning)
• 알고있는 샘플과 정답(레이블)을 이용한 학습
• 스팸필터, 붓꽃 품종, 암진단
• 비지도 학습(unsupervised learning)
• 정답이 없는 샘플을 이용하여 데이터를 재표현
• 차원축소, 군집
• 강화 학습(reinforcement learning)
• 환경으로부터 받은 보상을 이용하여 학습
• 게임, 로봇
11
딥 러닝의 분야
• 음성인식(Speech Recognition)
• Google Assistant
• Amazon Echo
• SKT NUGU
• 이미지인식(Image Recognition)
• Google Photo
• 자율주행 자동차
• 자연어처리(Natural Language Processing, NLP)
• 기계번역(Machine Translation)
• 챗봇(chatbot)
• 게임, 그림, 음악, 로봇, ...
12
손글씨 숫자 인식
• MNIST handwritten digits database
• http://yann.lecun.com/exdb/mnist/
13
텐서플로우 소개
14
머신 러닝 라이브러리
• scikit-learn (http://scikit-learn.org)
• 파이썬이 머신러닝 분야의 표준 언어
• Weka
http://www.cs.waikato.ac.nz/ml/weka/
• Apache Mahout, Spark ML, ...
15
딥 러닝 라이브러리
• TensorFlow(https://tensorflow.org)
• 2015년 11월 공개
• 구글이 개발, 지원
• 파이썬 API / 윈도우, 맥, 리눅스 지원
• 다양한 인공신경망 알고리즘 제공
• 계산 그래프 정의, 실행
• PyTorch(http://pytorch.org/)
• 페이스북 개발, 지원
• 다이나믹 계산 그래프
• MXNet, CNTK, Theano, Deeplearning4j, DyNet
• Torch, Caffe, Chainer
16
텐서플로우 리소스
• 텐서플로우 웹사이트
http://tensorflow.org
• 텐서플로우 깃허브
https://github.com/tensorflow/tensorflow
• 텐서플로우 커뮤니티
https://www.facebook.com/groups/TensorFlowKR/
• 텐서플로우 한글 문서
https://tensorflowkorea.gitbooks.io/tensorflow-kr/
• 텐서플로우 블로그
https://tensorflow.blog/
17
파이썬 소개
18
History
• 네덜란드 개발자 귀도 반 로섬(Guido van Rossum)이 1989년에 개발 시작
• 1994년 1.0 Release, 2000년에 2.0 Release, 2010년에 2.7 Release
• 2008년에 3.0 Release, 2015년에 3.5 Release, 2016년에 3.6 Release
• Python 2.7 버전은 2020년 까지만 지원
19
Guido van Rossum,
Dropbox 2012~
출처: wikipedia
Trend
20
US Worldwide
Advantage
• 오픈소스 범용 인터프리트 언어(no compile)
• 배우기 쉽고 코드를 읽기 좋다
• Battery Included
• 객체 지향 언어(Object Oriented Programming, OOP)
• 대화식 쉘(Interactive Shell): python, ipython
• 코드 + 결과 + 문서 : Jupyter notebook
• 풍부한 과학 기술 라이브러리(scikit-learn, scipy, numpy, pandas,...)
• 아나콘다(https://www.continuum.io/downloads)
• 캐노피(https://www.enthought.com/product/canopy)
• 더 풍부한 서드파티 라이브러리(pypi.python.org)
21
Python 2 vs 3
어떤 것을 써야할 지 잘 모르겠다면
파이썬 3이 적절합니다.
이미 파이썬 2로 작성한 코드가 많이 있거나
사용하고 있는 라이브러리가 파이썬 2 밖에
지원하지 않는 경우에는 파이썬 2를 사용합니다.
22
Comparison
23
Python Java Perl Ruby
dynamic type static type dynamic type dynamic type
interprete compile script interprete
less develop fast execute unreadable code less develop
battery included more modules
Flask, Django Spring, Struts Rails
strict indentation android text processing
more object-
oriented
more object-
oriented
less object-
oriented
more object-
oriented
Installer
• Mac & Linux
• come with python 2.7 out of the box
• python.org
• windows, mac
• linux 배포판 패키지 관리툴 (e.g. yum, apt-get)
• ActivaState, Canopy
• windows, mac, linux
• Anaconda
• continuum.io
• 720+ for stats, data mining, ml, dl, nlp, …
• include Numpy, SciPy, pandas, scikit-learn, Jupyter, NLTK, matplotlib, ...
24
Package
• 서드파티 라이브러리
• pypi.python.org
$ pip install package_name
$ conda install package_name
25
Script, Interactive shell
$ python script_name.py
$ python
$ ipython
26
~~~~~
~~~
Jupyter notebook
27
• 코드 + 문서 + 결과
• aka Ipython notebook
• julia, R, ruby
$ jupyter notebook
Notebook
28
Notebook Example
29
Github + notebook
30
파이썬과 텐서플로우 설치
31
Anaconda
• https://www.continuum.io/downloads
32
Anaconda Download
33
Anaconda Install
34
Anaconda Prompt
35
Python 3.5 Environment
>conda create -n tensorflow python=3.5 anaconda
36
Activate Environment
>activate tensorflow
37
Install TensorFlow
(tensorflow)>pip install tensorflow
38
Check TensorFlow
>ipython
…
In [1]: import tensorflow as tf
39
Notebook 연결
• 아마존 웹서비스 EC2에 있는 주피터 노트북에 접속하여 실습합니다.
• 브라우저로 아래 페이지에 있는 주피터 노트북 서버 주소로 연결하세요.
• 서버가 재 시작되면 주피터 노트북 주소가 매번 달라집니다.
40
폴더 생성
41
Untitled Folder 하나를 선택해서
각자 생일의 월일로 폴더를 만들어 주세요.
노트북 생성
42
자신의 폴더로 들어가
Python3 노트북을 하나 만듭니다.
노트북 이름 바꾸기
43
노트북의 이름을
적절한 이름으로 바꾸어 줍니다.
텐서플로우 테스트
44
노트북의 첫번째 셀에 ‘import tensorflow as tf’ 란 명령을 기입하고
Shift + Enter 를 눌러서 셀을 실행합니다.
아무런 메세지가 나오지 않으면 성공입니다.
셀(cell) 타입
45
기본적인 사용법
46
주의해야할 점
• 노트북 셀의 오브젝트(변수)는 노트북이 종료되면 모두 사라집니다.
• 다시 노트북을 열었을 때 출력 값은 보이지만 오브젝트는 메모리에 없습
니다.
• 오브젝트를 다시 만드려면 해당 셀을 다시 실행해야 합니다.
• 노트북 실행중에 상위 셀을 다시 실행하면 그로 인해 하위 오브젝트가 무
효화 될 수 있습니다.
47
파이썬 기초
48
print()
In [1]: print(“Hello World”)
Hello World
In [2]: print(‘Hello World’)
Hello World
In [3]: # comment
49
숫자(number)
In [1]: i = 10
In [2]: print(i)
10
In [3]: f = 10.0
In [4]: print(f)
10.0
50
문자열(string)
In [1]: str1 = “Hello World”
In [2]: print(str1)
Hello World
In [3]: str2 = “안녕 파이썬”
In [4]: print(str2)
안녕 파이썬
51
여러 변수 출력
In [1]: print(str1, str2)
Hello World 안녕 파이썬
In [2]: print(str1+str2)
Hello World안녕 파이썬
In [3]: print(str1+” ”+str2)
Hello World 안녕 파이썬
52
다른 타입의 변수 출력
In [1]: print(i, str1)
10 Hello World
In [2]: print(i+str1)
TypeError: unsupported operand type(s) for +: 'int' and
'str’
In [3]: type(i)
int
53
리스트(list)
In [1]: teams = []
In [2]: teams.append(1)
In [3]: print(teams)
[1]
In [4]: teams.append(2)
In [5]: print(teams)
[1, 2]
54
리스트에 여러 종류의 값
In [1]: teams = []
In [2]: teams.append(”Tottenham”)
In [3]: print(teams)
[1, 2, “Tottenham”]
In [4]: len(teams)
3
55
리스트 요소 선택
In [1]: print(teams[0])
1
In [2]: print(teams[2])
Tottenham
In [3]: print(teams[1:3])
[2, ‘Tottenham’]
In [4]: print(teams[0:2])
[0, 1]
56
문자열 요소 선택
In [1]: print(str1[0])
H
In [2]: print(str1[0:6])
Hello
In [3]: print(str1[-1])
d
In [3]: print(str1[-5:])
World
57
연산자
In [1]: sum = 1 + 2 + 3
In [2]: sum
6
In [3]: 4 * 5 / 2
10.0
In [4]: 4 * 5 // 2
10
58
제곱, 나머지
In [1]: 3 ** 2
9
In [2]: 3 ** 3
27
In [3]: 10 % 3
1
59
if
In [1]: if i == 10:
print(‘test ok’)
test ok
In [2]: if str1 == ‘Hello World’:
print(‘test valid’)
test valid
60
else
In [1]: if i <= 10:
print(‘less than 10’)
else:
print(‘more than 10’)
less than 10
61
elif
In [1]: if i < 10:
print(‘less than 10’)
elif i == 10:
print(‘equal 10’)
else:
print(‘more than 10’)
equal 10
62
if ~ in list
In [1]: if ‘Tottenham’ in teams:
print(‘sonny’)
sonny
In [2]: if ‘Tottenham’ in teams:
idx = teams.index(‘Tottenham’)
print(teams[idx])
Tottenham
63
for
In [1]: for name in teams:
print(name)
1
2
Tottenham
64
for ~ in range()
In [1]: for i in range(5):
print(i)
0
1
2
3
4
65
for ~ in range()
In [1]: for i in range(5):
if i % 2 == 0:
print(i)
continue
if i // 2 >= 1:
break
0
2
66
딕셔너리(dictionary)
In [1]: stat = {‘sonny’: 11, ‘kane’: 19}
In [2]: stat[‘sonny’]
11
In [3]: type(stat)
dict
In [4]: stat[‘alli’] = 16
In [5]: stat
{‘alli’: 16, ‘kane’: 19, ‘sonny’: 11}
67
복잡한 구조
In [1]: epl = {'team': teams, 'stat': stat}
In [2]: epl
{'stat': {'kane': 19, 'sonny': 11}, 'team': [1, 2]}
In [3]: epl = [teams, stat]
In [4]: epl
[[1, 2], {'kane': 19, 'sonny': 11}]
68
for ~ in dict
In [1]: for k in stat:
print(k, stat[k])
alli 16
sonny 11
kane 19
69
for ~ in dict.items()
In [1]: for k, v in stat.items():
print(k, v)
alli 16
sonny 11
kane 19
70
del()
In [1]: del(teams[2])
In [2]: teams
[1, 2]
In [3]: del(stat[‘alli’])
In [4]: stat
{‘kane’: 19, ‘sonny’: 11}
71
import
In [1]: import tensorflow
In [2]: tensorflow.constant(2)
<tf.Tensor 'Const:0' shape=() dtype=int32>
In [3]: import tensorflow as tf
In [4]: tf.constant(2)
<tf.Tensor 'Const:0' shape=() dtype=int32>
72
Python 온라인 문서
• 점프 투 파이썬:
https://wikidocs.net/book/1
• Think Python:
http://www.flowdas.com/thinkpython/
• A Byte of Python:
http://byteofpython-korean.sourceforge.net/byte_of_python.html
73
텐서플로우 기초
74
Graph 정의 + Session()
• 텐서플로우의 연산자를 사용하여 계산 구조를 정의합니다.
a = tf.constant(2)
b = tf.constant(3)
x = tf.add(a, b)
• 세션 객체를 만들어 만들어진 계산 그래프를 실행합니다.
x
<tf.Tensor 'Add:0' shape=() dtype=int32>
tf.Session().run(x)
5
75
텐서(Tensor)
• 다차원 배열, 매트릭스, NumPy 배열
• 텐서플로우에서 사용하는 데이터 표현
a.shape
TensorShape([])
c = tf.constant([2, 2])
c.shape
TensorShape([Dimension(2)])
76
상수(Constant)
d = tf.constant([[0, 1, 2], [3, 4, 5]])
d.shape
TensorShape([Dimension(2), Dimension(3)])
sess = tf.Session()
sess.run(d)
array([[0, 1, 2], [3, 4, 5]], dtype=int32)
77
행렬(matrix) 𝑑 =
0 1 2
3 4 5
zeros(), ones()
• 0으로 채워진 텐서를 만듭니다.
e = tf.zeros([2, 3])
tf.Session().run(e)
array([[ 0., 0., 0.], [ 0., 0., 0.]], dtype=float32)
• 1로 채워진 텐서를 만듭니다.
f = tf.ones([2, 3], dtype=tf.int32)
tf.Session().run(f)
array([[1, 1, 1], [1, 1, 1]], dtype=int32)
78
random_normal()
• 정규 분포(𝜇 = 0, 𝜎 = 1)의 난수를 발생시킵니다
g = tf.random_normal([2, 3])
tf.Session().run(g)
array([[-0.42949361, 2.13715839, -0.73751086],
[-0.56948185, -0.92247707, 0.62523431]],
dtype=float32)
79
truncated_normal()
• 정규 분포의 난수 중 표준편차의 두배 밖의 값은 제외합니다
h = tf.truncated_normal([2, 3])
tf.Session().run(h)
array([[ 1.09942925, -0.31089929, 0.39926037],
[-0.55724454, -0.41932136, -1.33153999]],
dtype=float32)
80
random_uniform()
• 균등 분포(0~1)의 난수를 발생시킵니다
p = tf.random_uniform([2, 3])
tf.Session().run(p)
array([[ 0.53323591, 0.19622314, 0.86946297],
[ 0.04974151, 0.95073402, 0.90066719]],
dtype=float32)
81
tf.add()
• 주어진 두 텐서를 더합니다.
a = tf.constant(10); b = tf.constant(20)
c = tf.add(a, b)
tf.Session().run(c)
30
d = tf.constant([10, 20]); e = tf.constant([20, 10])
f = d + e
tf.Session().run(f)
array([30, 30], dtype=int32)
82
tf.substrct()
• 주어진 두 텐서를 뺍니다.
a = tf.constant(10); b = tf.constant(20)
c = tf.subtract(a, b)
tf.Session().run(c)
-10
d = tf.constant([10, 20]); e = tf.constant([20, 10])
f = d - e
tf.Session().run(f)
array([-10, 10], dtype=int32)
83
tf.multiply()
• 주어진 두 텐서를 곱합니다.
a = tf.constant(10); b = tf.constant(20)
c = tf.multiply(a, b)
tf.Session().run(c)
200
d = tf.constant([10, 20]); e = tf.constant([20, 10])
f = d * e
tf.Session().run(f)
array([200, 200], dtype=int32)
84
tf.divide()
• 주어진 두 텐서를 곱합니다.
a = tf.constant(10); b = tf.constant(20)
c = tf.divide(a, b)
tf.Session().run(c)
0.5
d = tf.constant([10, 20]); e = tf.constant([20, 10])
f = d / e
tf.Session().run(f)
array([0.5, 2.], dtype=int32)
85
tf.Variable()
• 상수가 아니라 계산 그래프에서 변하는 값을 담는 도구입니다.
• 변수는 초깃값이 주어져야 하고 사용하기 전에 초기화 되어야 합니다.
a = tf.Variable(tf.constant(2))
a
<tensorflow.python.ops.variables.Variable at ...>
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)
sess.run(a)
2
86
assign()
• 변수의 값을 바꿉니다
a = tf.Variable(tf.constant(2))
upd = a.assign_add(tf.constant(3))
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)
sess.run(upd)
5
sess.run(upd)
8
87
tf.Variable(tf.random_normal())
• 변수를 생성할 때 랜덤한 값으로 초기화를 많이 합니다.
• random_normal(), truncated_normal(), random_uniform()
a = tf.Variable(tf.random_normal([2,3]))
sess = tf.Session()
sess.run(tf.global_variables_initializer())
sess.run(a)
array([[-1.4886378 , 0.28386045, 0.48322374],
[-1.92303669, -0.40773764, -0.11247366]],
dtype=float32)
88
행렬(matrix)
• 2×3 행렬
1 −2 2
3 −1 1
a = tf.Variable([[1, -2, 2], [3, -1, 1]])
sess = tf.Session()
sess.run(tf.global_variables_initializer())
sess.run(a[1][2])
1
89
행
(row)
열(column)
열(column)행(row)
tf.reduce_sum(a, 0)
• 행렬의 행방향으로 합을 계산합니다.
a = tf.Variable([[1, -2, 2], [3, -1, 1]])
asum = tf.reduce_sum(a, 0)
sess = tf.Session()
sess.run(tf.global_variables_initializer())
sess.run(asum)
array([ 4, -3, 3], dtype=int32)
90
1 −2 2
3 −1 1
4 −3 3
tf.reduce_sum(a, 1)
• 행렬의 열방향으로 합을 계산합니다.
a = tf.Variable([[1, -2, 2], [3, -1, 1]])
asum = tf.reduce_sum(a, 1)
sess = tf.Session()
sess.run(tf.global_variables_initializer())
sess.run(asum)
array([ 1, 3], dtype=int32)
asum = tf.reduce_sum(a)
sess.run(asum)
4
91
1 −2 2
3 −1 1
1 3
1 −2 2
3 −1 1
2. −1.5 1.5
tf.reduce_mean()
• 행렬의 행, 열방향으로 합을 계산합니다.
a = tf.Variable([[1., -2., 2.], [3., -1., 1.]])
amean = tf.reduce_mean(a, 0)
sess = tf.Session()
sess.run(tf.global_variables_initializer())
sess.run(amean)
array([ 2. , -1.5, 1.5], dtype=float32)
92
행렬 내적
• 행렬의 덧셈
• 2×3 + 2×3 = [2×3]
1 −2 2
3 −1 1
+
−1 3 2
2 4 1
=
0 1 4
5 3 2
• 행렬의 곱셈:	내적, 점곱(dot	product)
• 2×3 ⋅ 3×2 = [2×2]
1 −2 2
3 −1 1
2 −1
4 3
1 2
=
−4 −3
3 −4
93
행
(row)
열(column)
tf.matmul()
• 두개의 텐서를 입력 받아 행렬 내적을 계산합니다.
a = tf.Variable([[1, -2, 2], [3, -1, 1]])
b = tf.Variable([[2, -1], [4, 3], [1, 2]])
dot = tf.matmul(a, b)
sess = tf.Session()
sess.run(tf.global_variables_initializer())
sess.run(dot)
array([[-4, -3],
[ 3, -4]], dtype=int32)
94
1 −2 2
3 −1 1
2 −1
4 3
1 2
−4 −3
3 −4
신경망 학습은 반복된 과정
95
플레이스홀더
• 상수를 바꾸려면 그래프를 다시 만들어야 합니다.
• 변수는 그래프 내부의 계산에 의해 변경되는 값을 저장합니다.
• 그래프는 보통 반복적으로 실행되므로 그래프를 실행할 때 프로그래머가
데이터를 주입할 방법이 필요합니다.
96
상수
상수
계산 변수데이터
계산 그래프
tf.placeholder() & feed_dict
• 값을 지정하지 않은 플레이스 홀더를 만든 후 실행시에 값을 주입합니다.
a = tf.Variable([[1, -2, 2], [3, -1, 1]])
b = tf.placeholder(tf.int32, [3, 2])
dot = tf.matmul(a, b)
sess = tf.Session()
sess.run(tf.global_variables_initializer())
sess.run(dot, feed_dict={b: [[2, -1], [4, 3], [1, 2]]})
array([[-4, -3],
[ 3, -4]], dtype=int32)
97
Materials
• Github :
https://github.com/rickiepark/tfk-notebooks/tree/master/tensorflow_for_beginners
• Slideshare :
https://www.slideshare.net/RickyPark3/1introduction-to-python-and-
tensorflow
98
감사합니다.
99

Contenu connexe

Tendances

機械学習と深層学習の数理
機械学習と深層学習の数理機械学習と深層学習の数理
機械学習と深層学習の数理Ryo Nakamura
 
全体セミナー20170629
全体セミナー20170629全体セミナー20170629
全体セミナー20170629Jiro Nishitoba
 
時系列解析の使い方 - TokyoWebMining #17
時系列解析の使い方 - TokyoWebMining #17時系列解析の使い方 - TokyoWebMining #17
時系列解析の使い方 - TokyoWebMining #17horihorio
 
Decision Transformer: Reinforcement Learning via Sequence Modeling
Decision Transformer: Reinforcement Learning via Sequence ModelingDecision Transformer: Reinforcement Learning via Sequence Modeling
Decision Transformer: Reinforcement Learning via Sequence ModelingYasunori Ozaki
 
フーリエ変換と画像圧縮の仕組み
フーリエ変換と画像圧縮の仕組みフーリエ変換と画像圧縮の仕組み
フーリエ変換と画像圧縮の仕組みyuichi takeda
 
Modulation AM.pdf
Modulation AM.pdfModulation AM.pdf
Modulation AM.pdfHassnTAI
 
高速な倍精度指数関数expの実装
高速な倍精度指数関数expの実装高速な倍精度指数関数expの実装
高速な倍精度指数関数expの実装MITSUNARI Shigeo
 
[DL輪読会]Reward Augmented Maximum Likelihood for Neural Structured Prediction
[DL輪読会]Reward Augmented Maximum Likelihood for Neural Structured Prediction[DL輪読会]Reward Augmented Maximum Likelihood for Neural Structured Prediction
[DL輪読会]Reward Augmented Maximum Likelihood for Neural Structured PredictionDeep Learning JP
 
Outilsdanalysefonctionnellesadt 160919140831
Outilsdanalysefonctionnellesadt 160919140831Outilsdanalysefonctionnellesadt 160919140831
Outilsdanalysefonctionnellesadt 160919140831Lénaïc CAPELLE
 
Scikit-learnを使って 画像分類を行う
Scikit-learnを使って 画像分類を行うScikit-learnを使って 画像分類を行う
Scikit-learnを使って 画像分類を行うArata Honda
 
Résumer sur les fichier et les enregistrement
Résumer sur les fichier et les enregistrementRésumer sur les fichier et les enregistrement
Résumer sur les fichier et les enregistrementborhen boukthir
 
MCMCとともだちになろう【※Docswellにも同じものを上げています】
MCMCとともだちになろう【※Docswellにも同じものを上げています】MCMCとともだちになろう【※Docswellにも同じものを上げています】
MCMCとともだちになろう【※Docswellにも同じものを上げています】Hiroyuki Muto
 

Tendances (15)

機械学習と深層学習の数理
機械学習と深層学習の数理機械学習と深層学習の数理
機械学習と深層学習の数理
 
全体セミナー20170629
全体セミナー20170629全体セミナー20170629
全体セミナー20170629
 
React 2 trial
React 2 trialReact 2 trial
React 2 trial
 
Echantillonage
EchantillonageEchantillonage
Echantillonage
 
時系列解析の使い方 - TokyoWebMining #17
時系列解析の使い方 - TokyoWebMining #17時系列解析の使い方 - TokyoWebMining #17
時系列解析の使い方 - TokyoWebMining #17
 
Decision Transformer: Reinforcement Learning via Sequence Modeling
Decision Transformer: Reinforcement Learning via Sequence ModelingDecision Transformer: Reinforcement Learning via Sequence Modeling
Decision Transformer: Reinforcement Learning via Sequence Modeling
 
フーリエ変換と画像圧縮の仕組み
フーリエ変換と画像圧縮の仕組みフーリエ変換と画像圧縮の仕組み
フーリエ変換と画像圧縮の仕組み
 
Modulation AM.pdf
Modulation AM.pdfModulation AM.pdf
Modulation AM.pdf
 
高速な倍精度指数関数expの実装
高速な倍精度指数関数expの実装高速な倍精度指数関数expの実装
高速な倍精度指数関数expの実装
 
[DL輪読会]Reward Augmented Maximum Likelihood for Neural Structured Prediction
[DL輪読会]Reward Augmented Maximum Likelihood for Neural Structured Prediction[DL輪読会]Reward Augmented Maximum Likelihood for Neural Structured Prediction
[DL輪読会]Reward Augmented Maximum Likelihood for Neural Structured Prediction
 
Outilsdanalysefonctionnellesadt 160919140831
Outilsdanalysefonctionnellesadt 160919140831Outilsdanalysefonctionnellesadt 160919140831
Outilsdanalysefonctionnellesadt 160919140831
 
Scikit-learnを使って 画像分類を行う
Scikit-learnを使って 画像分類を行うScikit-learnを使って 画像分類を行う
Scikit-learnを使って 画像分類を行う
 
強化学習5章
強化学習5章強化学習5章
強化学習5章
 
Résumer sur les fichier et les enregistrement
Résumer sur les fichier et les enregistrementRésumer sur les fichier et les enregistrement
Résumer sur les fichier et les enregistrement
 
MCMCとともだちになろう【※Docswellにも同じものを上げています】
MCMCとともだちになろう【※Docswellにも同じものを上げています】MCMCとともだちになろう【※Docswellにも同じものを上げています】
MCMCとともだちになろう【※Docswellにも同じものを上げています】
 

Similaire à 1.Introduction to Python and TensorFlow

Lecture 1: Introduction to Python and TensorFlow
Lecture 1: Introduction to Python and TensorFlowLecture 1: Introduction to Python and TensorFlow
Lecture 1: Introduction to Python and TensorFlowSang Jun Lee
 
3. Install - Tensorflow
3. Install - Tensorflow3. Install - Tensorflow
3. Install - Tensorflowmerry7
 
구글 텐서플로우 첫걸음
구글 텐서플로우 첫걸음구글 텐서플로우 첫걸음
구글 텐서플로우 첫걸음Hwanhee Kim
 
EveryBody Tensorflow module1 GIST Jan 2018 Korean
EveryBody Tensorflow module1 GIST Jan 2018 KoreanEveryBody Tensorflow module1 GIST Jan 2018 Korean
EveryBody Tensorflow module1 GIST Jan 2018 KoreanJaewook. Kang
 
What's new tensorflow ( Tensorflow.js , Tensorflow Hub, Tensorflow Serving )
What's new tensorflow ( Tensorflow.js , Tensorflow Hub, Tensorflow Serving )What's new tensorflow ( Tensorflow.js , Tensorflow Hub, Tensorflow Serving )
What's new tensorflow ( Tensorflow.js , Tensorflow Hub, Tensorflow Serving )Gunhee Lee
 
Tensorflow
TensorflowTensorflow
Tensorflowchs71
 
[Tf2017] day1 jwkang_pub
[Tf2017] day1 jwkang_pub[Tf2017] day1 jwkang_pub
[Tf2017] day1 jwkang_pubJaewook. Kang
 
파이썬 데이터과학 1일차 - 초보자를 위한 데이터분석, 데이터시각화 (이태영)
파이썬 데이터과학 1일차 - 초보자를 위한 데이터분석, 데이터시각화 (이태영)파이썬 데이터과학 1일차 - 초보자를 위한 데이터분석, 데이터시각화 (이태영)
파이썬 데이터과학 1일차 - 초보자를 위한 데이터분석, 데이터시각화 (이태영)Tae Young Lee
 
2011 H3 컨퍼런스-파이썬으로 클라우드 하고 싶어요
2011 H3 컨퍼런스-파이썬으로 클라우드 하고 싶어요2011 H3 컨퍼런스-파이썬으로 클라우드 하고 싶어요
2011 H3 컨퍼런스-파이썬으로 클라우드 하고 싶어요Yongho Ha
 
H3 2011 파이썬으로 클라우드 하고 싶어요
H3 2011 파이썬으로 클라우드 하고 싶어요H3 2011 파이썬으로 클라우드 하고 싶어요
H3 2011 파이썬으로 클라우드 하고 싶어요KTH
 
H3 2011 파이썬으로 클라우드 하고 싶어요_분산기술Lab_하용호
H3 2011 파이썬으로 클라우드 하고 싶어요_분산기술Lab_하용호H3 2011 파이썬으로 클라우드 하고 싶어요_분산기술Lab_하용호
H3 2011 파이썬으로 클라우드 하고 싶어요_분산기술Lab_하용호KTH, 케이티하이텔
 
[NDC 2016] 유니티, iOS에서 LINQ 사용하기
[NDC 2016] 유니티, iOS에서 LINQ 사용하기[NDC 2016] 유니티, iOS에서 LINQ 사용하기
[NDC 2016] 유니티, iOS에서 LINQ 사용하기Daehee Kim
 
Python 활용: 이미지 처리와 데이터 분석
Python 활용: 이미지 처리와 데이터 분석Python 활용: 이미지 처리와 데이터 분석
Python 활용: 이미지 처리와 데이터 분석용 최
 
[3장] 딥러닝을 위한 환경 구축하기 | 수학 통계를 몰라도 이해할 수 있는 쉬운 딥러닝 | 반병현
[3장] 딥러닝을 위한 환경 구축하기 | 수학 통계를 몰라도 이해할 수 있는 쉬운 딥러닝  | 반병현[3장] 딥러닝을 위한 환경 구축하기 | 수학 통계를 몰라도 이해할 수 있는 쉬운 딥러닝  | 반병현
[3장] 딥러닝을 위한 환경 구축하기 | 수학 통계를 몰라도 이해할 수 있는 쉬운 딥러닝 | 반병현Byunghyun Ban
 

Similaire à 1.Introduction to Python and TensorFlow (20)

Lecture 1: Introduction to Python and TensorFlow
Lecture 1: Introduction to Python and TensorFlowLecture 1: Introduction to Python and TensorFlow
Lecture 1: Introduction to Python and TensorFlow
 
3. Install - Tensorflow
3. Install - Tensorflow3. Install - Tensorflow
3. Install - Tensorflow
 
JetsonTX2 Python
 JetsonTX2 Python  JetsonTX2 Python
JetsonTX2 Python
 
Lec 00, 01
Lec 00, 01Lec 00, 01
Lec 00, 01
 
구글 텐서플로우 첫걸음
구글 텐서플로우 첫걸음구글 텐서플로우 첫걸음
구글 텐서플로우 첫걸음
 
EveryBody Tensorflow module1 GIST Jan 2018 Korean
EveryBody Tensorflow module1 GIST Jan 2018 KoreanEveryBody Tensorflow module1 GIST Jan 2018 Korean
EveryBody Tensorflow module1 GIST Jan 2018 Korean
 
파이썬으로 익히는 딥러닝
파이썬으로 익히는 딥러닝파이썬으로 익히는 딥러닝
파이썬으로 익히는 딥러닝
 
What's new tensorflow ( Tensorflow.js , Tensorflow Hub, Tensorflow Serving )
What's new tensorflow ( Tensorflow.js , Tensorflow Hub, Tensorflow Serving )What's new tensorflow ( Tensorflow.js , Tensorflow Hub, Tensorflow Serving )
What's new tensorflow ( Tensorflow.js , Tensorflow Hub, Tensorflow Serving )
 
Tensorflow
TensorflowTensorflow
Tensorflow
 
[Tf2017] day1 jwkang_pub
[Tf2017] day1 jwkang_pub[Tf2017] day1 jwkang_pub
[Tf2017] day1 jwkang_pub
 
파이썬 데이터과학 1일차 - 초보자를 위한 데이터분석, 데이터시각화 (이태영)
파이썬 데이터과학 1일차 - 초보자를 위한 데이터분석, 데이터시각화 (이태영)파이썬 데이터과학 1일차 - 초보자를 위한 데이터분석, 데이터시각화 (이태영)
파이썬 데이터과학 1일차 - 초보자를 위한 데이터분석, 데이터시각화 (이태영)
 
2011 H3 컨퍼런스-파이썬으로 클라우드 하고 싶어요
2011 H3 컨퍼런스-파이썬으로 클라우드 하고 싶어요2011 H3 컨퍼런스-파이썬으로 클라우드 하고 싶어요
2011 H3 컨퍼런스-파이썬으로 클라우드 하고 싶어요
 
H3 2011 파이썬으로 클라우드 하고 싶어요
H3 2011 파이썬으로 클라우드 하고 싶어요H3 2011 파이썬으로 클라우드 하고 싶어요
H3 2011 파이썬으로 클라우드 하고 싶어요
 
H3 2011 파이썬으로 클라우드 하고 싶어요_분산기술Lab_하용호
H3 2011 파이썬으로 클라우드 하고 싶어요_분산기술Lab_하용호H3 2011 파이썬으로 클라우드 하고 싶어요_분산기술Lab_하용호
H3 2011 파이썬으로 클라우드 하고 싶어요_분산기술Lab_하용호
 
[NDC 2016] 유니티, iOS에서 LINQ 사용하기
[NDC 2016] 유니티, iOS에서 LINQ 사용하기[NDC 2016] 유니티, iOS에서 LINQ 사용하기
[NDC 2016] 유니티, iOS에서 LINQ 사용하기
 
IPython
IPythonIPython
IPython
 
Python 활용: 이미지 처리와 데이터 분석
Python 활용: 이미지 처리와 데이터 분석Python 활용: 이미지 처리와 데이터 분석
Python 활용: 이미지 처리와 데이터 분석
 
파이썬 데이터 분석 (18년)
파이썬 데이터 분석 (18년)파이썬 데이터 분석 (18년)
파이썬 데이터 분석 (18년)
 
파이썬 소개
파이썬 소개 파이썬 소개
파이썬 소개
 
[3장] 딥러닝을 위한 환경 구축하기 | 수학 통계를 몰라도 이해할 수 있는 쉬운 딥러닝 | 반병현
[3장] 딥러닝을 위한 환경 구축하기 | 수학 통계를 몰라도 이해할 수 있는 쉬운 딥러닝  | 반병현[3장] 딥러닝을 위한 환경 구축하기 | 수학 통계를 몰라도 이해할 수 있는 쉬운 딥러닝  | 반병현
[3장] 딥러닝을 위한 환경 구축하기 | 수학 통계를 몰라도 이해할 수 있는 쉬운 딥러닝 | 반병현
 

Plus de Haesun Park

사이킷런 최신 변경 사항 스터디
사이킷런 최신 변경 사항 스터디사이킷런 최신 변경 사항 스터디
사이킷런 최신 변경 사항 스터디Haesun Park
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 9장 텐서플로 시작하기
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 9장 텐서플로 시작하기[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 9장 텐서플로 시작하기
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 9장 텐서플로 시작하기Haesun Park
 
(Handson ml)ch.8-dimensionality reduction
(Handson ml)ch.8-dimensionality reduction(Handson ml)ch.8-dimensionality reduction
(Handson ml)ch.8-dimensionality reductionHaesun Park
 
(Handson ml)ch.7-ensemble learning and random forest
(Handson ml)ch.7-ensemble learning and random forest(Handson ml)ch.7-ensemble learning and random forest
(Handson ml)ch.7-ensemble learning and random forestHaesun Park
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리Haesun Park
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신Haesun Park
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련Haesun Park
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 3장. 분류
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 3장. 분류[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 3장. 분류
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 3장. 분류Haesun Park
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지Haesun Park
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝Haesun Park
 
7.woring with text data(epoch#2)
7.woring with text data(epoch#2)7.woring with text data(epoch#2)
7.woring with text data(epoch#2)Haesun Park
 
6.algorithm chains and piplines(epoch#2)
6.algorithm chains and piplines(epoch#2)6.algorithm chains and piplines(epoch#2)
6.algorithm chains and piplines(epoch#2)Haesun Park
 
5.model evaluation and improvement(epoch#2) 2
5.model evaluation and improvement(epoch#2) 25.model evaluation and improvement(epoch#2) 2
5.model evaluation and improvement(epoch#2) 2Haesun Park
 
5.model evaluation and improvement(epoch#2) 1
5.model evaluation and improvement(epoch#2) 15.model evaluation and improvement(epoch#2) 1
5.model evaluation and improvement(epoch#2) 1Haesun Park
 
4.representing data and engineering features(epoch#2)
4.representing data and engineering features(epoch#2)4.representing data and engineering features(epoch#2)
4.representing data and engineering features(epoch#2)Haesun Park
 
3.unsupervised learing(epoch#2)
3.unsupervised learing(epoch#2)3.unsupervised learing(epoch#2)
3.unsupervised learing(epoch#2)Haesun Park
 
2.supervised learning(epoch#2)-3
2.supervised learning(epoch#2)-32.supervised learning(epoch#2)-3
2.supervised learning(epoch#2)-3Haesun Park
 
2.supervised learning(epoch#2)-2
2.supervised learning(epoch#2)-22.supervised learning(epoch#2)-2
2.supervised learning(epoch#2)-2Haesun Park
 
2.supervised learning(epoch#2)-1
2.supervised learning(epoch#2)-12.supervised learning(epoch#2)-1
2.supervised learning(epoch#2)-1Haesun Park
 
1.introduction(epoch#2)
1.introduction(epoch#2)1.introduction(epoch#2)
1.introduction(epoch#2)Haesun Park
 

Plus de Haesun Park (20)

사이킷런 최신 변경 사항 스터디
사이킷런 최신 변경 사항 스터디사이킷런 최신 변경 사항 스터디
사이킷런 최신 변경 사항 스터디
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 9장 텐서플로 시작하기
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 9장 텐서플로 시작하기[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 9장 텐서플로 시작하기
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 9장 텐서플로 시작하기
 
(Handson ml)ch.8-dimensionality reduction
(Handson ml)ch.8-dimensionality reduction(Handson ml)ch.8-dimensionality reduction
(Handson ml)ch.8-dimensionality reduction
 
(Handson ml)ch.7-ensemble learning and random forest
(Handson ml)ch.7-ensemble learning and random forest(Handson ml)ch.7-ensemble learning and random forest
(Handson ml)ch.7-ensemble learning and random forest
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 3장. 분류
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 3장. 분류[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 3장. 분류
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 3장. 분류
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝
 
7.woring with text data(epoch#2)
7.woring with text data(epoch#2)7.woring with text data(epoch#2)
7.woring with text data(epoch#2)
 
6.algorithm chains and piplines(epoch#2)
6.algorithm chains and piplines(epoch#2)6.algorithm chains and piplines(epoch#2)
6.algorithm chains and piplines(epoch#2)
 
5.model evaluation and improvement(epoch#2) 2
5.model evaluation and improvement(epoch#2) 25.model evaluation and improvement(epoch#2) 2
5.model evaluation and improvement(epoch#2) 2
 
5.model evaluation and improvement(epoch#2) 1
5.model evaluation and improvement(epoch#2) 15.model evaluation and improvement(epoch#2) 1
5.model evaluation and improvement(epoch#2) 1
 
4.representing data and engineering features(epoch#2)
4.representing data and engineering features(epoch#2)4.representing data and engineering features(epoch#2)
4.representing data and engineering features(epoch#2)
 
3.unsupervised learing(epoch#2)
3.unsupervised learing(epoch#2)3.unsupervised learing(epoch#2)
3.unsupervised learing(epoch#2)
 
2.supervised learning(epoch#2)-3
2.supervised learning(epoch#2)-32.supervised learning(epoch#2)-3
2.supervised learning(epoch#2)-3
 
2.supervised learning(epoch#2)-2
2.supervised learning(epoch#2)-22.supervised learning(epoch#2)-2
2.supervised learning(epoch#2)-2
 
2.supervised learning(epoch#2)-1
2.supervised learning(epoch#2)-12.supervised learning(epoch#2)-1
2.supervised learning(epoch#2)-1
 
1.introduction(epoch#2)
1.introduction(epoch#2)1.introduction(epoch#2)
1.introduction(epoch#2)
 

1.Introduction to Python and TensorFlow

  • 2. Contacts • Haesun Park • email : haesunrpark@gmail.com • facebook : facebook.com/haesunrpark • blog : tensorflow.blog 2
  • 3. Book • 텐서플로 첫걸음 • First Contact with TensorFlow, Jordie Torres. • 온라인 : tensorflow.blog/2016/04/28/first- contact-with-tensorflow/ • Yes24 : yes24.com/24/goods/30547754 3
  • 4. Outlook • Part 1: 파이썬과 텐서플로우 소개 • Part 2: 회귀 분석과 로지스틱 회귀 • Part 3: 뉴럴 네트워크 알고리즘 • Part 4: 콘볼루션 뉴럴 네트워크 4
  • 6. 머신 러닝이란 “머신 러닝 또는 기계 학습은 인공 지능의 한 분야로, 컴퓨터가 학습할 수 있도록 하는 알고리즘과 기술을 개발하는 분야를 말한다.” - 위키피디아 “Field of study that gives computers the ability to learn without being explicitly programmed.” - Arthur Samuel, 1959 6
  • 7. AI ⊃ 머신러닝 ⊃ 딥러닝 • 딥러닝이란 인공신경망(Artificial Neural Network) 알고리즘을 사용한 머 신러닝의 한 분야이다. 7
  • 11. 머신 러닝 분류 • 감독 여부나 주어지는 정보에 따라 • 지도 학습(supervised learning) • 알고있는 샘플과 정답(레이블)을 이용한 학습 • 스팸필터, 붓꽃 품종, 암진단 • 비지도 학습(unsupervised learning) • 정답이 없는 샘플을 이용하여 데이터를 재표현 • 차원축소, 군집 • 강화 학습(reinforcement learning) • 환경으로부터 받은 보상을 이용하여 학습 • 게임, 로봇 11
  • 12. 딥 러닝의 분야 • 음성인식(Speech Recognition) • Google Assistant • Amazon Echo • SKT NUGU • 이미지인식(Image Recognition) • Google Photo • 자율주행 자동차 • 자연어처리(Natural Language Processing, NLP) • 기계번역(Machine Translation) • 챗봇(chatbot) • 게임, 그림, 음악, 로봇, ... 12
  • 13. 손글씨 숫자 인식 • MNIST handwritten digits database • http://yann.lecun.com/exdb/mnist/ 13
  • 15. 머신 러닝 라이브러리 • scikit-learn (http://scikit-learn.org) • 파이썬이 머신러닝 분야의 표준 언어 • Weka http://www.cs.waikato.ac.nz/ml/weka/ • Apache Mahout, Spark ML, ... 15
  • 16. 딥 러닝 라이브러리 • TensorFlow(https://tensorflow.org) • 2015년 11월 공개 • 구글이 개발, 지원 • 파이썬 API / 윈도우, 맥, 리눅스 지원 • 다양한 인공신경망 알고리즘 제공 • 계산 그래프 정의, 실행 • PyTorch(http://pytorch.org/) • 페이스북 개발, 지원 • 다이나믹 계산 그래프 • MXNet, CNTK, Theano, Deeplearning4j, DyNet • Torch, Caffe, Chainer 16
  • 17. 텐서플로우 리소스 • 텐서플로우 웹사이트 http://tensorflow.org • 텐서플로우 깃허브 https://github.com/tensorflow/tensorflow • 텐서플로우 커뮤니티 https://www.facebook.com/groups/TensorFlowKR/ • 텐서플로우 한글 문서 https://tensorflowkorea.gitbooks.io/tensorflow-kr/ • 텐서플로우 블로그 https://tensorflow.blog/ 17
  • 19. History • 네덜란드 개발자 귀도 반 로섬(Guido van Rossum)이 1989년에 개발 시작 • 1994년 1.0 Release, 2000년에 2.0 Release, 2010년에 2.7 Release • 2008년에 3.0 Release, 2015년에 3.5 Release, 2016년에 3.6 Release • Python 2.7 버전은 2020년 까지만 지원 19 Guido van Rossum, Dropbox 2012~ 출처: wikipedia
  • 21. Advantage • 오픈소스 범용 인터프리트 언어(no compile) • 배우기 쉽고 코드를 읽기 좋다 • Battery Included • 객체 지향 언어(Object Oriented Programming, OOP) • 대화식 쉘(Interactive Shell): python, ipython • 코드 + 결과 + 문서 : Jupyter notebook • 풍부한 과학 기술 라이브러리(scikit-learn, scipy, numpy, pandas,...) • 아나콘다(https://www.continuum.io/downloads) • 캐노피(https://www.enthought.com/product/canopy) • 더 풍부한 서드파티 라이브러리(pypi.python.org) 21
  • 22. Python 2 vs 3 어떤 것을 써야할 지 잘 모르겠다면 파이썬 3이 적절합니다. 이미 파이썬 2로 작성한 코드가 많이 있거나 사용하고 있는 라이브러리가 파이썬 2 밖에 지원하지 않는 경우에는 파이썬 2를 사용합니다. 22
  • 23. Comparison 23 Python Java Perl Ruby dynamic type static type dynamic type dynamic type interprete compile script interprete less develop fast execute unreadable code less develop battery included more modules Flask, Django Spring, Struts Rails strict indentation android text processing more object- oriented more object- oriented less object- oriented more object- oriented
  • 24. Installer • Mac & Linux • come with python 2.7 out of the box • python.org • windows, mac • linux 배포판 패키지 관리툴 (e.g. yum, apt-get) • ActivaState, Canopy • windows, mac, linux • Anaconda • continuum.io • 720+ for stats, data mining, ml, dl, nlp, … • include Numpy, SciPy, pandas, scikit-learn, Jupyter, NLTK, matplotlib, ... 24
  • 25. Package • 서드파티 라이브러리 • pypi.python.org $ pip install package_name $ conda install package_name 25
  • 26. Script, Interactive shell $ python script_name.py $ python $ ipython 26 ~~~~~ ~~~
  • 27. Jupyter notebook 27 • 코드 + 문서 + 결과 • aka Ipython notebook • julia, R, ruby $ jupyter notebook
  • 36. Python 3.5 Environment >conda create -n tensorflow python=3.5 anaconda 36
  • 39. Check TensorFlow >ipython … In [1]: import tensorflow as tf 39
  • 40. Notebook 연결 • 아마존 웹서비스 EC2에 있는 주피터 노트북에 접속하여 실습합니다. • 브라우저로 아래 페이지에 있는 주피터 노트북 서버 주소로 연결하세요. • 서버가 재 시작되면 주피터 노트북 주소가 매번 달라집니다. 40
  • 41. 폴더 생성 41 Untitled Folder 하나를 선택해서 각자 생일의 월일로 폴더를 만들어 주세요.
  • 42. 노트북 생성 42 자신의 폴더로 들어가 Python3 노트북을 하나 만듭니다.
  • 43. 노트북 이름 바꾸기 43 노트북의 이름을 적절한 이름으로 바꾸어 줍니다.
  • 44. 텐서플로우 테스트 44 노트북의 첫번째 셀에 ‘import tensorflow as tf’ 란 명령을 기입하고 Shift + Enter 를 눌러서 셀을 실행합니다. 아무런 메세지가 나오지 않으면 성공입니다.
  • 47. 주의해야할 점 • 노트북 셀의 오브젝트(변수)는 노트북이 종료되면 모두 사라집니다. • 다시 노트북을 열었을 때 출력 값은 보이지만 오브젝트는 메모리에 없습 니다. • 오브젝트를 다시 만드려면 해당 셀을 다시 실행해야 합니다. • 노트북 실행중에 상위 셀을 다시 실행하면 그로 인해 하위 오브젝트가 무 효화 될 수 있습니다. 47
  • 49. print() In [1]: print(“Hello World”) Hello World In [2]: print(‘Hello World’) Hello World In [3]: # comment 49
  • 50. 숫자(number) In [1]: i = 10 In [2]: print(i) 10 In [3]: f = 10.0 In [4]: print(f) 10.0 50
  • 51. 문자열(string) In [1]: str1 = “Hello World” In [2]: print(str1) Hello World In [3]: str2 = “안녕 파이썬” In [4]: print(str2) 안녕 파이썬 51
  • 52. 여러 변수 출력 In [1]: print(str1, str2) Hello World 안녕 파이썬 In [2]: print(str1+str2) Hello World안녕 파이썬 In [3]: print(str1+” ”+str2) Hello World 안녕 파이썬 52
  • 53. 다른 타입의 변수 출력 In [1]: print(i, str1) 10 Hello World In [2]: print(i+str1) TypeError: unsupported operand type(s) for +: 'int' and 'str’ In [3]: type(i) int 53
  • 54. 리스트(list) In [1]: teams = [] In [2]: teams.append(1) In [3]: print(teams) [1] In [4]: teams.append(2) In [5]: print(teams) [1, 2] 54
  • 55. 리스트에 여러 종류의 값 In [1]: teams = [] In [2]: teams.append(”Tottenham”) In [3]: print(teams) [1, 2, “Tottenham”] In [4]: len(teams) 3 55
  • 56. 리스트 요소 선택 In [1]: print(teams[0]) 1 In [2]: print(teams[2]) Tottenham In [3]: print(teams[1:3]) [2, ‘Tottenham’] In [4]: print(teams[0:2]) [0, 1] 56
  • 57. 문자열 요소 선택 In [1]: print(str1[0]) H In [2]: print(str1[0:6]) Hello In [3]: print(str1[-1]) d In [3]: print(str1[-5:]) World 57
  • 58. 연산자 In [1]: sum = 1 + 2 + 3 In [2]: sum 6 In [3]: 4 * 5 / 2 10.0 In [4]: 4 * 5 // 2 10 58
  • 59. 제곱, 나머지 In [1]: 3 ** 2 9 In [2]: 3 ** 3 27 In [3]: 10 % 3 1 59
  • 60. if In [1]: if i == 10: print(‘test ok’) test ok In [2]: if str1 == ‘Hello World’: print(‘test valid’) test valid 60
  • 61. else In [1]: if i <= 10: print(‘less than 10’) else: print(‘more than 10’) less than 10 61
  • 62. elif In [1]: if i < 10: print(‘less than 10’) elif i == 10: print(‘equal 10’) else: print(‘more than 10’) equal 10 62
  • 63. if ~ in list In [1]: if ‘Tottenham’ in teams: print(‘sonny’) sonny In [2]: if ‘Tottenham’ in teams: idx = teams.index(‘Tottenham’) print(teams[idx]) Tottenham 63
  • 64. for In [1]: for name in teams: print(name) 1 2 Tottenham 64
  • 65. for ~ in range() In [1]: for i in range(5): print(i) 0 1 2 3 4 65
  • 66. for ~ in range() In [1]: for i in range(5): if i % 2 == 0: print(i) continue if i // 2 >= 1: break 0 2 66
  • 67. 딕셔너리(dictionary) In [1]: stat = {‘sonny’: 11, ‘kane’: 19} In [2]: stat[‘sonny’] 11 In [3]: type(stat) dict In [4]: stat[‘alli’] = 16 In [5]: stat {‘alli’: 16, ‘kane’: 19, ‘sonny’: 11} 67
  • 68. 복잡한 구조 In [1]: epl = {'team': teams, 'stat': stat} In [2]: epl {'stat': {'kane': 19, 'sonny': 11}, 'team': [1, 2]} In [3]: epl = [teams, stat] In [4]: epl [[1, 2], {'kane': 19, 'sonny': 11}] 68
  • 69. for ~ in dict In [1]: for k in stat: print(k, stat[k]) alli 16 sonny 11 kane 19 69
  • 70. for ~ in dict.items() In [1]: for k, v in stat.items(): print(k, v) alli 16 sonny 11 kane 19 70
  • 71. del() In [1]: del(teams[2]) In [2]: teams [1, 2] In [3]: del(stat[‘alli’]) In [4]: stat {‘kane’: 19, ‘sonny’: 11} 71
  • 72. import In [1]: import tensorflow In [2]: tensorflow.constant(2) <tf.Tensor 'Const:0' shape=() dtype=int32> In [3]: import tensorflow as tf In [4]: tf.constant(2) <tf.Tensor 'Const:0' shape=() dtype=int32> 72
  • 73. Python 온라인 문서 • 점프 투 파이썬: https://wikidocs.net/book/1 • Think Python: http://www.flowdas.com/thinkpython/ • A Byte of Python: http://byteofpython-korean.sourceforge.net/byte_of_python.html 73
  • 75. Graph 정의 + Session() • 텐서플로우의 연산자를 사용하여 계산 구조를 정의합니다. a = tf.constant(2) b = tf.constant(3) x = tf.add(a, b) • 세션 객체를 만들어 만들어진 계산 그래프를 실행합니다. x <tf.Tensor 'Add:0' shape=() dtype=int32> tf.Session().run(x) 5 75
  • 76. 텐서(Tensor) • 다차원 배열, 매트릭스, NumPy 배열 • 텐서플로우에서 사용하는 데이터 표현 a.shape TensorShape([]) c = tf.constant([2, 2]) c.shape TensorShape([Dimension(2)]) 76
  • 77. 상수(Constant) d = tf.constant([[0, 1, 2], [3, 4, 5]]) d.shape TensorShape([Dimension(2), Dimension(3)]) sess = tf.Session() sess.run(d) array([[0, 1, 2], [3, 4, 5]], dtype=int32) 77 행렬(matrix) 𝑑 = 0 1 2 3 4 5
  • 78. zeros(), ones() • 0으로 채워진 텐서를 만듭니다. e = tf.zeros([2, 3]) tf.Session().run(e) array([[ 0., 0., 0.], [ 0., 0., 0.]], dtype=float32) • 1로 채워진 텐서를 만듭니다. f = tf.ones([2, 3], dtype=tf.int32) tf.Session().run(f) array([[1, 1, 1], [1, 1, 1]], dtype=int32) 78
  • 79. random_normal() • 정규 분포(𝜇 = 0, 𝜎 = 1)의 난수를 발생시킵니다 g = tf.random_normal([2, 3]) tf.Session().run(g) array([[-0.42949361, 2.13715839, -0.73751086], [-0.56948185, -0.92247707, 0.62523431]], dtype=float32) 79
  • 80. truncated_normal() • 정규 분포의 난수 중 표준편차의 두배 밖의 값은 제외합니다 h = tf.truncated_normal([2, 3]) tf.Session().run(h) array([[ 1.09942925, -0.31089929, 0.39926037], [-0.55724454, -0.41932136, -1.33153999]], dtype=float32) 80
  • 81. random_uniform() • 균등 분포(0~1)의 난수를 발생시킵니다 p = tf.random_uniform([2, 3]) tf.Session().run(p) array([[ 0.53323591, 0.19622314, 0.86946297], [ 0.04974151, 0.95073402, 0.90066719]], dtype=float32) 81
  • 82. tf.add() • 주어진 두 텐서를 더합니다. a = tf.constant(10); b = tf.constant(20) c = tf.add(a, b) tf.Session().run(c) 30 d = tf.constant([10, 20]); e = tf.constant([20, 10]) f = d + e tf.Session().run(f) array([30, 30], dtype=int32) 82
  • 83. tf.substrct() • 주어진 두 텐서를 뺍니다. a = tf.constant(10); b = tf.constant(20) c = tf.subtract(a, b) tf.Session().run(c) -10 d = tf.constant([10, 20]); e = tf.constant([20, 10]) f = d - e tf.Session().run(f) array([-10, 10], dtype=int32) 83
  • 84. tf.multiply() • 주어진 두 텐서를 곱합니다. a = tf.constant(10); b = tf.constant(20) c = tf.multiply(a, b) tf.Session().run(c) 200 d = tf.constant([10, 20]); e = tf.constant([20, 10]) f = d * e tf.Session().run(f) array([200, 200], dtype=int32) 84
  • 85. tf.divide() • 주어진 두 텐서를 곱합니다. a = tf.constant(10); b = tf.constant(20) c = tf.divide(a, b) tf.Session().run(c) 0.5 d = tf.constant([10, 20]); e = tf.constant([20, 10]) f = d / e tf.Session().run(f) array([0.5, 2.], dtype=int32) 85
  • 86. tf.Variable() • 상수가 아니라 계산 그래프에서 변하는 값을 담는 도구입니다. • 변수는 초깃값이 주어져야 하고 사용하기 전에 초기화 되어야 합니다. a = tf.Variable(tf.constant(2)) a <tensorflow.python.ops.variables.Variable at ...> init = tf.global_variables_initializer() sess = tf.Session() sess.run(init) sess.run(a) 2 86
  • 87. assign() • 변수의 값을 바꿉니다 a = tf.Variable(tf.constant(2)) upd = a.assign_add(tf.constant(3)) init = tf.global_variables_initializer() sess = tf.Session() sess.run(init) sess.run(upd) 5 sess.run(upd) 8 87
  • 88. tf.Variable(tf.random_normal()) • 변수를 생성할 때 랜덤한 값으로 초기화를 많이 합니다. • random_normal(), truncated_normal(), random_uniform() a = tf.Variable(tf.random_normal([2,3])) sess = tf.Session() sess.run(tf.global_variables_initializer()) sess.run(a) array([[-1.4886378 , 0.28386045, 0.48322374], [-1.92303669, -0.40773764, -0.11247366]], dtype=float32) 88
  • 89. 행렬(matrix) • 2×3 행렬 1 −2 2 3 −1 1 a = tf.Variable([[1, -2, 2], [3, -1, 1]]) sess = tf.Session() sess.run(tf.global_variables_initializer()) sess.run(a[1][2]) 1 89 행 (row) 열(column) 열(column)행(row)
  • 90. tf.reduce_sum(a, 0) • 행렬의 행방향으로 합을 계산합니다. a = tf.Variable([[1, -2, 2], [3, -1, 1]]) asum = tf.reduce_sum(a, 0) sess = tf.Session() sess.run(tf.global_variables_initializer()) sess.run(asum) array([ 4, -3, 3], dtype=int32) 90 1 −2 2 3 −1 1 4 −3 3
  • 91. tf.reduce_sum(a, 1) • 행렬의 열방향으로 합을 계산합니다. a = tf.Variable([[1, -2, 2], [3, -1, 1]]) asum = tf.reduce_sum(a, 1) sess = tf.Session() sess.run(tf.global_variables_initializer()) sess.run(asum) array([ 1, 3], dtype=int32) asum = tf.reduce_sum(a) sess.run(asum) 4 91 1 −2 2 3 −1 1 1 3
  • 92. 1 −2 2 3 −1 1 2. −1.5 1.5 tf.reduce_mean() • 행렬의 행, 열방향으로 합을 계산합니다. a = tf.Variable([[1., -2., 2.], [3., -1., 1.]]) amean = tf.reduce_mean(a, 0) sess = tf.Session() sess.run(tf.global_variables_initializer()) sess.run(amean) array([ 2. , -1.5, 1.5], dtype=float32) 92
  • 93. 행렬 내적 • 행렬의 덧셈 • 2×3 + 2×3 = [2×3] 1 −2 2 3 −1 1 + −1 3 2 2 4 1 = 0 1 4 5 3 2 • 행렬의 곱셈: 내적, 점곱(dot product) • 2×3 ⋅ 3×2 = [2×2] 1 −2 2 3 −1 1 2 −1 4 3 1 2 = −4 −3 3 −4 93 행 (row) 열(column)
  • 94. tf.matmul() • 두개의 텐서를 입력 받아 행렬 내적을 계산합니다. a = tf.Variable([[1, -2, 2], [3, -1, 1]]) b = tf.Variable([[2, -1], [4, 3], [1, 2]]) dot = tf.matmul(a, b) sess = tf.Session() sess.run(tf.global_variables_initializer()) sess.run(dot) array([[-4, -3], [ 3, -4]], dtype=int32) 94 1 −2 2 3 −1 1 2 −1 4 3 1 2 −4 −3 3 −4
  • 96. 플레이스홀더 • 상수를 바꾸려면 그래프를 다시 만들어야 합니다. • 변수는 그래프 내부의 계산에 의해 변경되는 값을 저장합니다. • 그래프는 보통 반복적으로 실행되므로 그래프를 실행할 때 프로그래머가 데이터를 주입할 방법이 필요합니다. 96 상수 상수 계산 변수데이터 계산 그래프
  • 97. tf.placeholder() & feed_dict • 값을 지정하지 않은 플레이스 홀더를 만든 후 실행시에 값을 주입합니다. a = tf.Variable([[1, -2, 2], [3, -1, 1]]) b = tf.placeholder(tf.int32, [3, 2]) dot = tf.matmul(a, b) sess = tf.Session() sess.run(tf.global_variables_initializer()) sess.run(dot, feed_dict={b: [[2, -1], [4, 3], [1, 2]]}) array([[-4, -3], [ 3, -4]], dtype=int32) 97
  • 98. Materials • Github : https://github.com/rickiepark/tfk-notebooks/tree/master/tensorflow_for_beginners • Slideshare : https://www.slideshare.net/RickyPark3/1introduction-to-python-and- tensorflow 98