pytorch

Pytorch (2-3) - ๋‰ด์Šค ์นดํ…Œ๊ณ ๋ฆฌ ๋ถ„๋ฅ˜ํ•˜๊ธฐ

๋‰ด์Šค ๋ง๋ญ‰์น˜๋ฅผ ๋‹ค์šด๋กœ๋“œ ๋ฐ›์•„์„œ ๋ถ„์„ํ•ด๋ณด์ž. ๋ง๋ญ‰์น˜๋Š” [์—ฌ๊ธฐ](http://www.kristalinfo.com/download/hkib-20000-40075.tar.gz)์—์„œ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค. ๊ณผ๊ฑฐ ๋‰ด์Šค ๋ฐ์ดํ„ฐ๋ฅผ ๋‹ค์šด๋กœ๋“œํ•ด์„œ, ์–ด๋–ค ์นดํ…Œ์ฝ”๋ฆฌ์ธ์ง€ ๋ถ„๋ฅ˜ํ•˜๋Š” ํ•™์Šต์„ ์ง„ํ–‰ํ•ด๋ณด์ž. ๋จผ์ € ๊ตฌ๊ธ€๋“œ๋ผ์ด๋ธŒ์— ํ•ด๋‹น ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•ด์„œ ์ง„ํ–‰ํ–ˆ๋‹ค. ๋ฌผ๋ก  ์•„๋ž˜์™€ ๊ฐ™์€ ์ฝ”๋“œ๋กœ cola...

Read
pytorch

Pytorch (2-2) - ์† ๊ธ€์”จ ๋ถ„๋ฅ˜ํ•˜๊ธฐ

## ์†๊ธ€์”จ ๋ถ„๋ฅ˜ํ•˜๊ธฐ (MNIST) ๋จธ์‹ ๋Ÿฌ๋‹์˜ ๋‹จ๊ณจ ์ฃผ์ œ๋‹ค. ์†๊ธ€์”จ๋ฅผ ๋ถ„๋ฅ˜ํ•ด๋ณด์ž. ์ด์ „ ๋ฐ์ดํ„ฐ์™€ ๋‹ค๋ฅธ ์ ์ด๋ผ๊ณ  ํ•œ๋‹ค๋ฉด, ์ด์ „ ๋ฐ์ดํ„ฐ๋Š” ํ‘œ ํ˜•์‹์ด์—ˆ์ง€๋งŒ, ์ด์ œ๋Š” ์ด๋ฏธ์ง€ ํ˜•์‹์œผ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋‹ค. ```python import torch from torch.autograd import Variable import torch.nn as nn import tor...

Read
pytorch

Pytorch (2-1) - ๋‹ค์ธต ํผ์…‰ํŠธ๋ก 

์ „์—๋Š” ์‹ ๊ฒฝ๋ง์—์„œ ์ค‘๊ฐ„์ธต์„ ํ•˜๋‚˜๋กœ๋งŒ ํ–ˆ์ง€๋งŒ, ์ด ์ค‘๊ฐ„์ธต์„ ์—ฌ๋Ÿฌ๊ฐœ๋กœ ๋Š˜๋ฆฐ ๊ฒƒ์„ ์‹ฌ์ธต์‹ ๊ฒฝ๋ง (deep neural network) ๋ผ๊ณ  ํ•œ๋‹ค. ๋ฒŒ์จ ๋ถ€ํ„ฐ ๋ญ”๊ฐ€ ์žˆ์–ด๋ณด์ธ๋‹ค. ์ด๋Š” ๋”ฅ๋Ÿฌ๋‹์—์„œ ์ฃผ์š” ๋งค์ปค๋‹ˆ์ฆ˜์ด๋‹ค. ์‹ ๊ฒฝ๋ง๊ณผ ์‹ฌ์ธต ์‹ ๊ฒฝ๋ง ๋ชจ๋‘ ํผ์…‰ํŠธ๋ก ์„ ์—ฌ๋Ÿฌ๊ฐœ ์กฐํ•ฉํ•ด์„œ ๊ตฌ์„ฑํ•œ ๊ฒƒ์œผ๋กœ, ๋‹ค์ธต ํผ์…‰ํŠธ๋ก  (multilayer perceptron, MLP)๋ผ๊ณ  ํ•œ๋‹ค. ์–ด์ฉ„๊ฑฐ...

Read
pytorch

Pytorch (1) - ํผ์…‰ํŠธ๋ก  ์•Œ๊ณ ๋ฆฌ์ฆ˜๊ณผ ์‹ ๊ฒฝ๋ง ์•Œ๊ณ ๋ฆฌ์ฆ˜

## ํผ์…‰ํŠธ๋ก  ์•Œ๊ณ ๋ฆฌ์ฆ˜ ํผ์…‰ํŠธ๋ก  ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ๋จธ์‹ ๋Ÿฌ๋‹ ๊ธฐ๋ฒ• ์ค‘ ์ง€๋„ํ•™์Šต ๊ธฐ๋ฒ•์ด์ž ๋ถ„๋ฅ˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์— ์†ํ•œ๋‹ค. ![neuron-and-perceptron](https://appliedgo.net/media/perceptron/neuron.png) ๊ฐ๊ฐ์˜ input์— ์ž…๋ ฅ๊ฐ’๊ณผ ๊ฐ€์ค‘์น˜๋ฅผ ๊ณฑํ•œ ๊ฐ’์„ ํ•ฉํ•œ ๋‹ค์Œ, ๋ฐ”์ด์–ด์Šค (=1)๋ฅผ ๋”ํ•œ ๊ฐ’์ด ๋œ๋‹ค. ๊ทธ ๋‹ค์Œ์—๋Š” ํ™œ...

Read

Step by Step machine learning - 05

## Training Models ### ์ •๊ทœ ๋ฐฉ์ •์‹์„ ํ™œ์šฉํ•œ ์„ ํ˜• ํšŒ๊ท€ ```python import numpy as np X = 2 * np.random.rand(100, 1) y = 4 + 3 * X + np.random.randn(100, 1) ``` ํ…Œ์ŠคํŠธ ์šฉ์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๋งŒ๋“ค์–ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ```python plt.plot(X, y, "...

Read