PowerPoint 프레젠테이션

Similar documents
Multi-pass Sieve를 이용한 한국어 상호참조해결 반-자동 태깅 도구

Introduction to Deep learning

딥러닝 첫걸음

Microsoft PowerPoint - 실습소개와 AI_ML_DL_배포용.pptx

1-1-basic-43p

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

<4D F736F F D20B1E2C8B9BDC3B8AEC1EE2DC0E5C7F5>

PowerPoint Presentation

THE JOURNAL OF KOREAN INSTITUTE OF ELECTROMAGNETIC ENGINEERING AND SCIENCE Jul.; 29(7),

김기남_ATDC2016_160620_[키노트].key

Ch 1 머신러닝 개요.pptx

PowerPoint 프레젠테이션

( 분류및특징 ) 학습방법에따라 1 지도학습 (Supervised 2 비지도 학습 (Unsupervised 3 강화학습 (Reinforcement 으로구분 3) < 머신러닝의학습방법 > 구분 지도학습 (Supervised 비지도학습 (Unsupervised 강화학습 (

Artificial Intelligence: Assignment 6 Seung-Hoon Na December 15, Sarsa와 Q-learning Windy Gridworld Windy Gridworld의 원문은 다음 Sutton 교재의 연습문제

DIY 챗봇 - LangCon

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

Artificial Intelligence: Assignment 5 Seung-Hoon Na December 15, Numpy: Tutorial 다음 자료를 참조하여 numpy기본을 공부하시오.

MATLAB and Numerical Analysis

01 AI Definition 02 Deep Learning Theory - Linear Regression - Cost Function - Gradient Descendent - Logistic Regression - Activation Function - Conce

17장 클래스와 메소드

Microsoft PowerPoint - Java7.pptx

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각

<4D F736F F F696E74202D203137C0E55FBFACBDC0B9AEC1A6BCD6B7E7BCC72E707074>

슬라이드 1

신경망 (Neural Networks) < 인공지능입문 > 강의 허민오 Biointelligence Laboratory School of Computer Science and Engineering Seoul National University

2 : (Seungsoo Lee et al.: Generating a Reflectance Image from a Low-Light Image Using Convolutional Neural Network) (Regular Paper) 24 4, (JBE

Multi-pass Sieve를 이용한 한국어 상호참조해결 반-자동 태깅 도구

PowerPoint Presentation

example code are examined in this stage The low pressure pressurizer reactor trip module of the Plant Protection System was programmed as subject for

PowerPoint Presentation

Microsoft PowerPoint - ch07 - 포인터 pm0415

슬라이드 1

PowerPoint 프레젠테이션

Vector Differential: 벡터 미분 Yonghee Lee October 17, 벡터미분의 표기 스칼라미분 벡터미분(Vector diffrential) 또는 행렬미분(Matrix differential)은 벡터와 행렬의 미분식에 대 한 표

빅데이터_DAY key

_KrlGF발표자료_AI

Microsoft Word _mentor_conf_output5.docx

API STORE 키발급및 API 사용가이드 Document Information 문서명 : API STORE 언어별 Client 사용가이드작성자 : 작성일 : 업무영역 : 버전 : 1 st Draft. 서브시스템 : 문서번호 : 단계 : Docum

3 Gas Champion : MBB : IBM BCS PO : 2 BBc : : /45

Chap 6: Graphs

23_Time-Series-Prediction

Algorithm_Trading_Simple

Microsoft PowerPoint - 알고리즘_5주차_1차시.pptx

예제 1.1 ( 관계연산자 ) >> A=1:9, B=9-A A = B = >> tf = A>4 % 4 보다큰 A 의원소들을찾을경우 tf = >> tf = (A==B) % A

비트와바이트 비트와바이트 비트 (Bit) : 2진수값하나 (0 또는 1) 를저장할수있는최소메모리공간 1비트 2비트 3비트... n비트 2^1 = 2개 2^2 = 4개 2^3 = 8개... 2^n 개 1 바이트는 8 비트 2 2

RNN & NLP Application

<4D F736F F D20C3D6BDC C0CCBDB4202D20BAB9BBE7BABB>

Delving Deeper into Convolutional Networks for Learning Video Representations - Nicolas Ballas, Li Yao, Chris Pal, Aaron Courville arXiv:

데이터 시각화

<313120C0AFC0FCC0DA5FBECBB0EDB8AEC1F2C0BB5FC0CCBFEBC7D15FB1E8C0BAC5C25FBCF6C1A42E687770>

Software Requirrment Analysis를 위한 정보 검색 기술의 응용

Asia-pacific Journal of Multimedia Services Convergent with Art, Humanities, and Sociology Vol.7, No.11, November (2017), pp

2002년 2학기 자료구조

<4E505F415AB1DBB7CEB9FABAF1C1EEC7C3B7A35FBEE0B0FC E687770>

4 : CNN (Sangwon Suh et al.: Dual CNN Structured Sound Event Detection Algorithm Based on Real Life Acoustic Dataset) (Regular Paper) 23 6, (J

19_9_767.hwp

Chapter 11 Rate of Reaction


Manufacturing6

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202839C1D6C2F7207E203135C1D6C2F >

사회통계포럼

학습목차 2.1 다차원배열이란 차원배열의주소와값의참조

ºÎ·ÏB

PowerPoint 프레젠테이션

High Resolution Disparity Map Generation Using TOF Depth Camera In this paper, we propose a high-resolution disparity map generation method using a lo

(JBE Vol. 24, No. 2, March 2019) (Special Paper) 24 2, (JBE Vol. 24, No. 2, March 2019) ISSN

슬라이드 1

Parallel Computation of Neural Network

about_by5

PowerPoint 프레젠테이션

C# Programming Guide - Types

(JBE Vol. 23, No. 2, March 2018) (Special Paper) 23 2, (JBE Vol. 23, No. 2, March 2018) ISSN

Journal of Educational Innovation Research 2018, Vol. 28, No. 3, pp DOI: NCS : * A Study on

(JBE Vol. 21, No. 1, January 2016) (Regular Paper) 21 1, (JBE Vol. 21, No. 1, January 2016) ISSN 228

딥러닝튜토리얼 Deep Learning Tutorial - 신경망과딥러닝의이해 Understanding Neural Network & Deep Learning

Buy one get one with discount promotional strategy

(JBE Vol. 23, No. 5, September 2018) (Special Paper) 23 5, (JBE Vol. 23, No. 5, September 2018) ISSN

03.Agile.key

Microsoft PowerPoint - AC3.pptx

PowerPoint Presentation

강의10

Microsoft PowerPoint - chap-03.pptx

Lab - Gradient descent Copyright 2018 by Introduction [PDF 파일다운로드 ]() 이번랩은우리가강의를통해들은 Gradient descent 을활용하여 LinearRegression

Gray level 변환 및 Arithmetic 연산을 사용한 영상 개선

(JBE Vol. 23, No. 4, July 2018) (Special Paper) 23 4, (JBE Vol. 23, No. 4, July 2018) ISSN

김경재 안현철 지능정보연구제 17 권제 4 호 2011 년 12 월

CS322 중간고사.docx

SOSCON-MXNET_1014

OR MS와 응용-03장

Sequences with Low Correlation

<31302E204D43545F47535FC3D6C1BEBAB8B0EDBCAD2E687770>

중간고사

02 C h a p t e r Java

산선생의 집입니다. 환영해요

R을 이용한 텍스트 감정분석

<4D F736F F D20B1E2C8B9BDC3B8AEC1EE2DB0FBB3EBC1D8>

, ( ) 1) *.. I. (batch). (production planning). (downstream stage) (stockout).... (endangered). (utilization). *

[ReadyToCameral]RUF¹öÆÛ(CSTA02-29).hwp

Transcription:

Introduction to Deep Learning and Neural Networks Vision Modeling Lab. Division of Electrical Engineering Hanyang University, ERICA Campus

2 Contents Machine learning Artificial Neural Network (ANN) 신경망의역사와최근의딥러닝 Python & Numpy Python & Numpy란? 예제 PyTorch Linear Regression 예제 PyTorch 를이용한수기 (Handwritten) 숫자분류기구현

3 Machine learning 머신러닝 ( 영어 : machine learning) 또는기계학습 ( 機械學習 ) 은인공지능의한분야로, 컴퓨터가학습할수있도록하는알고리즘과기술을개발하는분야를말한다. 가령, 기계학습을통해서수신한이메일이스팸인지아닌지를구분할수있도록훈련할수있다. 1959 년, 아서사무엘은기계학습을 컴퓨터에게배울수있는능력, 즉코드로정의하지않은동작을실행하는능력에대한연구분야 라고정의하였다. -Wikipedia

4 Machine learning Supervised learning Classification Regression UnSupervised learning Clustering Underlying Probability Density Estimation SVM(Classification) SemiSupervised learning Reinforcement learning 군집화 (Clustering) 참고문헌 : Wikipedia

5 최근딥러닝의결과 http://news.unist.ac.kr/kor/column_202/ https://devblogs.nvidia.com/photo-editing-generativeadversarial-networks-2/ https://github.com/mitmul/chainer-fast-rcnn https://youtu.be/dlc4ylsauss

출력신력신호6 인공신경망 (ANN) 입 뉴런의구조 호사진출처 : https://m.blog.naver.com/postview.nhn?blogid=samsjang&logno= 입력신호의합이역치를넘으면출력단에신호 ( 자극 ) 을보냄. 220948258166&proxyReferer=https%3A%2F%2Fwww.google.co.kr%2F

7 인공신경망 (ANN) 퍼셉트론구조 x1 x2 w1 w2 Activation function x3 w3 ΣΣ xi wi ΣΣww ii xx ii = ww TT xx 입력단에가중치를곱한것의합이 activation function 의역치를넘기면 1 을그렇지않으면 -1 을넘겨주도록모델링함.

8 퍼셉트론의동작예제 OR 분류문제 c a d b a = (0,0), tt aa = 1 b = (1,0), tt bb = 1 c = (0,1), tt cc = 1 d = (1,1), tt dd = 1 - + c d Solution! d(x,y) = yy + xx 1 2 = 0 a b * 엄밀히 unique 한 sol 은아님 d(x,y)

9 퍼셉트론의동작예제 OR 분류문제 d(x,y) = yy + xx 1 + = 0 2 c d - a b 퍼셉트론구조에적용! 1-0.5 ττ ss = +1, ss 0 1, ss < 0 Activation function x y 1 ΣΣ 1 ΣΣww ii xx ii = ww TT xx

10 퍼셉트론의동작예제 Does it really work? dd aa = 0 + 0 1 2 = 1 2 ττ dd aa = 1 dd bb = 0 + 1 1 2 = 1 2 dd cc = 1 + 0 1 2 = 1 2 dd dd = 1 + 1 1 2 = 3 2 ττ dd bb = 1 ττ dd cc = 1 ττ dd dd = 1 It works! c a d b a = (0,0), tt aa = 1 b = (1,0), tt bb = 1 c = (0,1), tt cc = 1 d = (1,1), tt dd = 1

퍼셉트론학습 퍼셉트론학습이란? 훈련집합 XX = xx 11, tt 11, xx 11, tt 11,, xx NN, tt NN 이주어졌을때이들을옳게분류하는퍼셉트론을찾는것. 즉, ww 와 bb 를찾는문제가됨. 11 x1 x2 w1 w2 Activation function x3 w3 ΣΣ xi wi ΣΣww ii xx ii = ww TT xx

12 퍼셉트론학습 일반적인패턴인식의학습알고리즘의설계 3 단계 1. 분류기구조를정의하고분류과정을수학적으로표현. Ex) 단일퍼셉트론구조등 2. 분류기의품질을측정할수있는비용함수 JJ(θθ) 를정의. Ex) JJ(θθ) = ff(ww TT xx + bb) yy, ff xx : aaaaaaaaaaaaaaaaaaaa ffffffff 3. JJ(θθ) 를최대최소로하는 θθ 를찾기위한알고리즘을설계. JJ θθ 0 인 θθ 를찾아야하며, 최적화알고리즘으로 gradient descent 등이있음.

13 Gradient descent method Main idea JJ(θθ) iiiiiiiiiiii pppppppppp JJ mmmmmm (θθ) θθ 사진출처 : https://rasbt.github.io/mlxtend/user_guide/general_concepts/gradientoptimization/

14 Sigmoid Gradient descent method 는미분가능해야사용가능! Sigmoid function 비선형함수 전구간미분가능함. 계산이간단하며, 미분한값역시계산이간단함. Binary mode, Bipolar mode가있음. Binary mode Bipolar mode 사진출처 : https://www.intechopen.com/books/speech-technologies/nonlinear-dimensionality-reduction-methodsfor-use-with-automatic-speech-recognition

15 Relu function Sigmoid 보다더좋은성능을보이는 Relu function! Relu function Sigmoid function 의미분함수의양단은 0 에가까워지므로, 학습이진행될수록 gradient 가 0 에수렴해질가능성이생긴다. Relu function 은 미분계산이매우간단해짐 학습속도가매우빨라진다 ( 빠르게수렴 ) Input node 의반이 0 의값을가지게됨으로써 hidden node 가 sparse 해지는효과를갖고, over fitting 문제를완화해준다. 사진출처 : http://bluediary8.tistory.com/2

16 Gradient descent method Update rule θθ h + 1 = θθ h ρρ h JJ θθ θθ, ρρ h : 학습률 ww h + 1 = ww h + ρρ(h) bb h + 1 = bb h + ρρ(h) JJ θθ ww JJ θθ bb ww h + 1 = ww h + ρρ(h) xxkk YY tt kk xx kk ) ww = ww bb, xx kk = xx kk 1

OR 분류기학습예제 JJ(θθ) = xxkk YY( tt kk )(ww TT xx kk + bb) Y는책정된 θθ가틀리게분류한샘플집합. tt kk 가양수이며, 오분류된경우, ww TT xx kk + bb < 0 tt kk ww TT xx kk + bb > 0 tt kk 가음수이며, 오분류된경우, ww TT xx kk + bb > 0 tt kk ww TT xx kk + bb > 0 따라서, θθ 가적절히분류하는경우에는 cost function 이줄어들게되어있음. 17 grrrrrrrrrrrrrr dddddddddddddd mmmmmmmmmmm θθ h + 1 = θθ h ρρ h JJ θθ θθ, ρρ h : 학습률 JJ θθ ww JJ θθ bb = xx kk YY tt kk xx kk = xx kk YY tt kk ww h + 1 = ww h + ρρ(h) xxkk YY tt kk xx kk bb h + 1 = bb h + ρρ(h) xxkk YY tt kk ww h + 1 = ww h + ρρ(h) xxkk YY tt kk xx kk ) ww = ww bb, xx kk = xx kk 1

18 OR 분류기학습예제 JJ(θθ) = xxkk YY( tt kk )(ww TT xx kk + bb) Init: ww 0 = 0.5,0.75 TT, bb 0 = 0.375 dd xx = 0.5xx 1 + 0.75xx 2 + 0.375 (1) 1 st generation YY = aa, bb ww 1 = ww 0 + 0.4 tt aa aa + tt bb bb = 0.5 0.75 + 0.4 0 0 + 1 0 bb 1 = bb 0 + 0.4 tt aa + tt bb = 0.375 + 0.4 0 = 0.375 = 0.1 0.75, dd xx = 0.1xx 1 + 0.75xx 2 + 0.375 (2) YY = a ww 2 = ww 1 + 0.4 tt aa aa = 0.1 0.75 + 0.4 0 0 bb 2 = bb 1 + 0.4 tt aa = 0.375 0.4 = 0.025 dd xx = 0.1xx 1 + 0.75xx 2 0.025 (3) YY = b ww 3 = ww 2 + 0.4 tt bb bb = 0.1 0.75 + 0.4 1 0 bb 3 = bb 2 + 0.4 tt bb = 0.025 + 0.4 = 0.375 2 nd generation = 0.1 0.75, 3 rd generation = 0.3 0.75, 참고문헌 : OR 분류기학습예제 - 패턴인식 ( 오일석 )

19 OR 분류기학습예제 dd xx = 0.3xx 1 + 0.75xx 2 + 0.375 (4) YY = aa ww 4 = ww 3 + 0.4 tt aa aa = 0.3 0.75 + 0.4 0 0 bb 4 = bb 3 + 0.4 tt aa = 0.375 0.4 = 0.025 dd xx = 0.3xx 1 + 0.75xx 2 0.025 (5) 4 th generation = 0.3 0.75, 5 th generation 4 5 c a d b 2 1 3

20 다층퍼셉트론의필요성 XOR 등의선형분리불가능한상황을다룬다면? c d?? c d a 단일직선으론분류불가능 ( 선형분리불가 ) b b a - + + - 두개의직선으로분류문제해결!

21 XOR 문제와 MLP c d a + b - perceptron1 + - perceptron2 sample Feature vector 1 st process 2 nd process x1 x2 percep1 percep2 percep3 a 0 0-1 +1-1 b 1 0 +1 +1 +1 c 0 1 +1 +1 +1 d 1 1 +1-1 -1

22 XOR 문제와 MLP 1-0.5 Activation function x y 1 x y 1 ΣΣ 1 1.5-1 ΣΣ -1 ΣΣww ii xx ii = ww TT xx Activation function ΣΣww ii xx ii = ww TT xx percep1 percep2 1 x y -1.0 1 ΣΣ 1 Activation function ΣΣww ii xx ii = ww TT xx percep3 Multilayer perceptron (MLP)

23 General MLP 전방계산 dd zz ssssss jj = xx ii uu iiii + uu 0jj ii=0 zz jj = ττ zz ssssmmjj pp oo ssssss kk = zz jj vv jjjj + vv 0kk jj=1 oo kk = ττ(oo ssssss kk ) 사진출처 : 패턴인식 ( 오일석 )

Back propagation algorithm Back propagation algorithm 이란전방계산이후출력층에서출발하여반대방향으로오류를줄이는방향으로의가중치를갱신하는알고리듬이다. 24 Update! Update! Error Calculation 사진출처 : 패턴인식 ( 오일석 )

25 History of Neural Networks 자료출처 : Junmo Kim, Deep Learning for Computer Vision

26 Recent deep learning Convolutional Neural Networks (CNN) 이미지를위한딥러닝 이미지컨볼루션연산을기본으로함 제한된영역안에서만반응하는시각신경세포구조를닮음 자료출처 : Lecun et al., 1998, http://ufldl.stanford.edu/tutorial/supervised/featureextractionusingconvolution/

27 Recent deep learning Convolutional Neural Networks (CNN) Alexnet Object categorization을위한네트워크 7 레이어, 650K 뉴런, 60M 파라메터 2개의 GPU 사용일주일간학습 ImageNet challenge 2012에서우승 2등과는인식률 10% 차이 이후발전을거듭해현재의딥러닝은물체분류를사람보다잘함 자료출처 : Krizhevsky et al., NIPS 2012

28 Recent deep learning Recurrent Neural Network (RNN) http://colah.github.io/posts/2015-08-understanding-lstms/ https://vsubhashini.github.io/s2vt.html

29 Recent deep learning Memory network 정보를저장하고이를바탕으로복잡한판단을수행 자료출처 : Sukhbaatar et al., 2015

30 Recent deep learning Generative Adversarial Network Unsupervised learning 학습데이터셋과비슷한이미지를생성하는네트워크 Generator 와 Discriminator 가경쟁하며학습 https://sthalles.github.io/intro-to-gans/, Redford et al., 2016

Python Python이란? 파이썬은 1991년프로그래머인귀도벤로섬이발표한프로그래밍언어 인터프리터식, 객체지향적, 동적타이핑대화형언어 파이썬의특징 인간의언어와유사함 간결하여사용하기쉬움 비동기식코딩 자바보다뛰어난멀티패러다임접근방식 파이썬과다른언어와의차이점 컴파일언어인 C 와달리인터프리터언어인파이썬은느린경우가많음 C와같은형식이긴하나더간단하고명료한편. 파이썬은여러언어들의특성들을가져온객체지향성언어. 31 참고문헌 : Wikipedia, 점프투파이썬

Python Python 에서의객체 (Object) Python 에서의객체라는것은함수, 모듈, 리스트, 튜플등모든것을객체라고칭함. 32 Import Package 파이썬에선라이브러리를통해다른프로그래밍을할수있음. EX)Numpy, TensorFlow, Matplotlib 참고문헌 : Wikipedia, 점프투파이썬, 누구나할수있는프로그래밍

Run Pycharm Pycharm 이란? 파이참은파이썬의 IDE(Integrated Development Environment). IDE 는통합개발환경으로개발자가소프트웨어개발과정에서필요한모든작업을하나의소프트웨어처리할수있도록환경제공. 파이참시작하기 33 참고문헌 : Wikipedia

34 Python 예제 Print function usages For + If/else 참고문헌 : Sjchoi101 Github

35 Python 예제 Make a function String operations

36 Python 예제 List Dictionary

37 Python 예제 Class

38 Python 예제 For 문을이용한 list print 함수와행렬곱을생성 for 문행렬곱함수 아래주어진 list로행렬곱을실행하는함수를만들것. 행렬사이즈가맞지않으면메시지를출력 (if문) 함수를사용하여실제로행렬곱한결과를출력할것 참고문헌 : Sjchoi101 Github

NumPy Numpy 란? Numerical Python 의줄임말로고성능의수치계산을하기위해만들어진 Python package 효율적인데이터분석위한툴 Numpy 의특징 벡터, 매트릭스고수준의배열과학계산이가능 입력값세트를통해계산이반복될때배열로데이터를나타내는것이자연스럽고편함. Numpy 의핵심기능은 C 로구현 ( 파이썬용 C 라이브러리 ) BLAS/LAPACK 기반 빠른수치계산을위한 structured Array 제공 오직같은종류의데이터만을배열에추가할수있음 39 참고문헌 : Wikipedia, http://www.numpy.org/

40 NumPy Python List vs NumPy Array Python List 여러가지타입의원소 메모리용량이크고속도가느림 Nesting 가능 전체연산불가능 Numpy Array 동일타입의원소 메모리최적화및계산속도향상 크기 (dimension) 이명확하게정의 전체연산가능

41 Numpy 예제 Load Packages, Rank n array Random(uniform,Gaussian) 참고문헌 : Sjchoi101 Github

42 Numpy 예제 Generation ones, zeros, Identity Product and addition and Matrix product

43 Numpy 예제 Get Row

44 Numpy 예제 Data Types & Array math

45 Numpy 예제 행렬 A,B,C,D 를만들어식을실행하는코드를만들기 다음수식을계산하는함수를만들것. 행렬은같은차원을가지고있어야함 행렬끼리차원이맞지않으면메시지를출력 곱셈은행렬곱으로이루어짐 완성된함수를바탕으로여러입력행렬을처리하고그결과를출력하는코드를만들것.

matplotlib Matplotlib 파이썬라이브러리중플롯을그릴때주로쓰이는 2D,3D 플로팅패키지이다 46

47 matplotlib Matplotlib 식과그림을보고 line2 를만들어내자

Pytorch Pytorch 란? 파이토치 (Pytorch) 는딥러닝라이브러리로계산그래프를정의하는데있어서 tensorflow 보다용의하며최근그유용성으로인해많은관심을받고있는라이브러리이다. 48 Computational graph? 계산그래프는수학계산과데이터의흐름을노드 (Node) 와엣지 (Edge) 사용한방향그래프 (Directed Graph) 로표현한다. 노드는수학적계산, 데이터입 / 출력, 그리고데이터의읽기 / 저장등의작업을수행한다 엣지는노드들간데이터의입출력관계를나타낸다. 엣지동적사이즈의다차원데이터배열 (= 텐서 ) 을실어나르게된다. 참고문헌 : Wikipedia, Tensorflow internal from Cho Hyunghun

Pytorch Pytorch 특징 Dynamic computational graph 생성을통한프로그래밍의용의함 Numpy 와 python 친화적인인터페이스 데이터처리나기존의모델을편하게사용할수있는라이브러리제공 Multi-GPU, Multi-CPU 를활용한분산컴퓨팅을제공 Python 과 C++ 를지원 Pytorch 개념 오퍼레이션 (Operation) 텐서를입력으로임의의계산을수행함 Pytorch 는동적으로 tensor 와 operation 을통해계산그래프를생성함 텐서 (Tensor) 원래의미는 2 차원이상의배열이지만 pytorch 에선임의의차원을가진배열을의미 네트워크의처리결과값과입력받은데이터등다양한정보를담을수있음 49 참고문헌 : Wikipedia, Tensorflow internal from Cho Hyunghun

Pytorch 계산그래프를사용하는이유는? 딥러닝네트워크를학습하기위해서는입력과 loss 함수사이의네트워크에대한미분을계산하는것이필요하다. 미분은 chain rule 을통하여계산됨으로연산과 tensor 사이의종속관계를저장하는것이필요하다. 또한계산그래프는함수의역할을함으로변하는입력데이터에대하여같은 operation 을적용할수있게된다. 50 Pytorch 예제및 corresponding computation graph 참고문헌 : Wikipedia, Tensorflow internal from Cho Hyunghun

Pytorch 다양한실행모드 싱글디바이스혹은멀티디바이스등다양한디바이스에서수행가능 51 Client process Master process Worker Process 1 GPU Worker Process 2 GPU Worker Process 3 GPU GPU CPU GPU CPU GPU CPU 참고문헌 : Wikipedia, Tensorflow internal from Cho Hyunghun

Pytorch 예제 (linear regression) 52

53 Pytorch 예제 (linear regression) Pytorch, numpy, matplotlib Load Packages 파이썬에서필요한 Package 를 import 하여사용 Load packages np.random.random(x,y): x*y 짜리 random np array 를생성. np.zeros(x,y): x*y 짜리 zeros np array 생성 np.random.normal: x*y 짜리 normal distribution 으로부터추출된 np array 생성 Prepare train point set <-solution

Pytorch 예제 (linear regression) Plot training data plt.figure(x): x번째 figure generate plt.plot(x,y,color,label): x좌표와 y좌표를갖는포인트들을 color로플롯팅 plt.legend(): lengend의위치조정관장 54 pytorch 변수선언 tensor: gradient 계산에포함되는변수선언입력과모델 parameter 등이이에해당하며 require_grad 인자를통해 gradient 를 update 의영향을받을지말지를결정하는것이가능하다.

55 Pytorch 예제 (linear regression) 변수와데이터 X,Y의선형관계를정의한다.(30) aaaaaaaaaaaaaaaaaaaa( AA 와 BB 로추정된 YY) = AAAA + BB Mean Square Error 로 cost function 을정의한다.(31) 1 nn nn ii=1 aaaaaaaaaaaaaaaaaann ii YY ii 2 최적화방법을정의해준다.(26) torch.optim.sgd([parameters], learning_rate) 모델계산과 loss 식계산

Pytorch 예제 (linear regression) Forward propagation 의결과를이용하여 back loss 를계산하고 parameter 를 update 함 (37~39) Update 된결과 W b 와변화한 loss 값을매 step 출력함 (41~42) 매 25 step 마다 W b 값을이용하여추정된선을 plot 함 (44~47) 56

57 Pytorch 예제 (linear regression) 결과물 Solution was (a = 0.25, b = 0.76)

Pytorch 예제 (linear regression) yy = xx 22 + aaaa + bb, a= 0.25, b = 0.75 에 noise 를추가한 train set 을학습시켜, a 와 b 를얻어내기

Multi Layer Perceptron MNIST Example 전체코드

Multi Layer Perceptron MNIST Example 전체코드

61 Multi Layer Perceptron MNIST Example 라이브러리 import, train/test set 불러오기 Mnist set Set Network parameter 2층의 hidden layer를갖는 MLP network 구축 ( 총 4층 ) Input과 output, hidden layer의노드숫자설정 결과 plot 을위한 list 정의 input model output MLP 0 x = 28*28 image y = label

62 Multi Layer Perceptron MNIST Example MLP 의구조, 동작정의 xx = ssssssssssssss WW 11 TT XX + bb 11 : hidden layer 1 xx = dddddddddddddd ssssssssssssss WW 22 TT xx 11 + bb 22 : hidden layer 2 + dropout * dropout 은과적합을막기위해 weight 을일정확률로끊기위한테크닉 return llllgg_ssssssssssssss(oooooooooooo xx ) 사용할 layer, activation function 등정의 Layer 와 activation function 등을활용해동작정의

Multi Layer Perceptron MNIST Example model 생성, criterion 과 optimizer 정의 gpu 가사용가능할경우 gpu 에서계산 앞서정의한 class 대로 model 생성 criterion 은 NLL(negative log likelihood)loss 로, 모델의 output 으로나온결과와실제 label 을비교 Optimizer 은 adam optimizer 를사용 63 training parameters training_epochs: 학습할횟수 (epoch: 세대 ) batch_size: model 이한번에계산할 image 의개수 (Dataloader 에서 batch size 가필요하기때문에순서상앞쪽에정의함 )

Multi Layer Perceptron MNIST Example Train train 을위한 model 설정 mnist_dataloader 가제공하는각 batch 에대해 loss 를계산하고 backpropagation 수행, loss 누적 누적된 loss 를평균을취하고결과 plot 을위해 epoch 과평균 loss 를기록 해당 epoch 에대한정보를출력 64

Multi Layer Perceptron MNIST Example Test test 을위한 model 설정 testloader 가제공하는각 batch 에대해 loss 를계산하여누적, 마지막에평균을취함 test data 에대해 model 이내놓은결과값 ( 확률 ) 이가장높은것과실제 label(target) 이나타내는것이같은개수를셈 test average loss, accuracy 출력 65

Multi Layer Perceptron MNIST Example Train & Test, Plot Graph 설정한 epoch 수만큼을돌며 train 과 test 를반복 학습이모두끝나면 epoch 의증가에따른 loss 의감소를나타내는그래프를출력 66

67 Multi Layer Perceptron MNIST Example Result

Multi Layer Perceptron MNIST Example 파라미터 (running rate, training_epochs 등 ) 와, layer 의수나 node 의수등모델을변화시켜, 성능을늘려봅시다! 68.95 이상의성능을내는모델과파라미터세팅을구현하기

69 참고문헌 오일석, 패턴인식 박응용, 점프투파이썬 www.numpy.org www.scipy.org https://github.com/sjchoi86/tensorflow-101 Tensorflow internal from Cho Hyunghun

70 참고문헌 Books : 패턴인식, 오일석 Deep learning book, Ian Goodfellow Library documentation : Pytorch : https://pytorch.org/docs/stable/tensors.html Numpy : http://www.numpy.org/ Scipy : https://www.scipy.org/ Python : https://docs.python.org/ko/3/ Tutorial documentation : Distilled pytorch tutorial : https://towardsdatascience.com/pytorch-tutorial-distilled- 95ce8781a89c

71

72

73

74 C:\ProgramData\anaconda3\tensorflow \env\python.exe C:\Users\kyujin\AppData\Local\conda \tensorflow\env\python.exe