[Transformer] Self-Attension ์…€ํ”„ ์–ดํ…์…˜ (0)
ยท
๐Ÿ‘พ Deep Learning
input#1์„ ๊ธฐ์ค€์œผ๋กœ #2, #3์™€์˜ ๊ด€๊ณ„๋ฅผ score๋กœ ๋งŒ๋“ค๊ณ  output #1์„ ๋งŒ๋“ ๋‹ค. ๊ทธ๋ฆฌ๊ณ  #2์™€ #1, #3์™€์˜ score๋ฅผ ๊ตฌํ•˜๊ณ  ๋‹ค์Œ #์œผ๋กœ ๋„˜์–ด๊ฐ€๋ฉด์„œ score๋ฅผ ๊ตฌํ•œ๋‹ค. ์ด ์ ์ˆ˜ score๋ฅผ ๋ชจ์•„ attention map์„ ๋งŒ๋“ ๋‹ค. 1. Illustrations The illustrations are divided into the following steps: Prepare inputs Initialise weights Derive key, query and value Calculate attention scores for Input 1 Calculate softmax Multiply scores with values Sum weighted values to get Output 1 ..
VAE(Variational Autoencoder) (3) MNIST
ยท
๐Ÿ‘พ Deep Learning
www.tensorflow.org/tutorials/generative/cvae?hl=ko ์ปจ๋ณผ๋ฃจ์…”๋„ ๋ณ€์ดํ˜• ์˜คํ† ์ธ์ฝ”๋” | TensorFlow Core ์ด ๋…ธํŠธ๋ถ์€ MNIST ๋ฐ์ดํ„ฐ์„ธํŠธ์—์„œ ๋ณ€์ดํ˜• ์˜คํ† ์ธ์ฝ”๋”(VAE, Variational Autoencoder)๋ฅผ ํ›ˆ๋ จํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค(1 , 2). VAE๋Š” ์˜คํ† ์ธ์ฝ”๋”์˜ ํ™•๋ฅ ๋ก ์  ํ˜•ํƒœ๋กœ, ๋†’์€ ์ฐจ์›์˜ ์ž…๋ ฅ ๋ฐ์ดํ„ฐ๋ฅผ ๋” ์ž‘์€ ํ‘œํ˜„ www.tensorflow.org Data load from IPython import display import glob import imageio import matplotlib.pyplot as plt import numpy as np import PIL import tensorflow as tf import tensor..
Tensorflow Initializer ์ดˆ๊ธฐํ™” ์ข…๋ฅ˜
ยท
๐Ÿ‘พ Deep Learning
RBM ์ƒ์ˆ˜ ์ดˆ๊ธฐํ™” (Zeros. Ones, Constant) class Constant: Initializer that generates tensors with constant values class Ones: Initializer that generates tensors initialized to 1. class Zeros: Initializer that generates tensors initialized to 0. class VarianceScaling: Initializer capable of adapting its scale to the shape of weights tensors. ์„ ํ˜• ์ดˆ๊ธฐํ™” (Orthogonal, Identity) class Orthogonal: Initializer th..
VAE(Variational Autoencoder) (2)
ยท
๐Ÿ‘พ Deep Learning
reparameterization trick VAE๋Š” ์ž…๋ ฅ์„ ์žฌํ˜„ํ•˜๋„๋ก ํ•™์Šตํ•œ๋‹ค. ํ™•๋ฅ  ๋ถ„ํฌ์— ๋”ฐ๋ผ ์ƒ˜ํ”Œ๋งํ•œ ๋ฐ์ดํ„ฐ๊ฐ€ ์ค‘๊ฐ„์— ์žˆ์Šค์œผ๋ฏ€๋กœ ํŽธ๋ฏธ๋ถ„, ์—ญ์ „ํŒŒ ๋‘˜๋‹ค ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค. ๋”ฐ๋ผ์„œ VAE๋Š” reparameterization trick์ด๋ผ๋Š” ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•œ๋‹ค. reparameterization trick์€ ํ‰๊ท  = 0 ํ‘œ์ค€ํŽธ์ฐจ = 1 ์ •๊ทœํ™”๋ถ„ํฌ๋ฅผ ๋”ฐ๋ฅธ๋‹ค. z = μ + ฯตσ ฯต์— ํ‘œ์ค€ํŽธ์ฐจ(σ)๋ฅผ ๊ณฑํ•œ ํ›„ ํ‰๊ท  μ๋ฅผ ๋”ํ•ด ๊ณ„์‚ฐํ•œ๋‹ค. VAE ์žฌ๊ตฌ์„ฑ ์˜ค์ฐจ
VAE(Variational Autoencoder) (1)
ยท
๐Ÿ‘พ Deep Learning
VAE(Variational Autoencoder)๋Š” ์˜คํ† ์ธ์ฝ”๋”(์ž๊ธฐ๋ถ€ํ˜ธํ™”๊ธฐ)๋ผ๋Š” ์‹ ๊ฒฝ๋ง์˜ ๋ฐœ์ „ ํ˜•ํƒœ๋ฅผ ๊ธฐ๋ฐ˜์— ๋‘์—ˆ๋‹ค. ์˜คํ† ์ธ์ฝ”๋”๋Š” ์ธ์ฝ”๋”์™€ ๋””์ฝ”๋”๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋‹ค. [Autoencoder] ์ž…๋ ฅ๊ณผ ์ถœ๋ ฅ์˜ ํฌ๊ธฐ๋Š” ๊ฐ™๊ณ , ์€๋‹‰์ธต์˜ ํฌ๊ธฐ๋Š” ๊ทธ๋ณด๋‹ค ์ž‘๋‹ค. ์‹ ๊ฒฝ๋ง์€ ์ถœ๋ ฅ์—์„œ ์ž…๋ ฅํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ์žฌํ˜„ํ•˜๋„๋ก ํ•™์Šตํ•˜์ง€๋งŒ, ์€๋‹‰์ธต์˜ ํฌ๊ธฐ๋Š” ์ž…๋ ฅ๋ณด๋‹ค ์ž‘๋‹ค. ์ธ์ฝ”๋”๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์••์ถ•ํ•˜๊ณ  ๋””์ฝ”๋”๋กœ ์••์ถ•ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ์›๋ž˜ ๋ฐ์ดํ„ฐ๋กœ ๋ณต์›ํ•œ๋‹ค. ์ž…๋ ฅ ๋ฐ์ดํ„ฐ๊ฐ€ ์ด๋ฏธ์ง€๋ผ๋ฉด ์€๋‹‰์ธต์€ ์ธ์ฝ”๋”์™€ ๋””์ฝ”๋”๋ฅผ ์ด์šฉํ•ด ์›๋ž˜ ์ด๋ฏธ์ง€๋ณด๋‹ค ์ ์€ ๋ฐ์ดํ…จ ์–‘์œผ๋กœ ์ด๋ฏธ์ง€์˜ ํŠน์ง•์„ ์œ ์ง€ ํ•œ๋‹ค. ์ฆ‰ ์˜คํ† ์ธ์ฝ”๋”๋Š” ์‹ ๊ฒฝ๋ง์„ ์ด์šฉํ•œ ์ž…๋ ฅ์˜ ์••์ถ•๊ณผ ๋ณต์›์ด๋ผ๊ณ  ์ดํ•ดํ•˜๋ฉด ์‰ฝ๋‹ค. ์˜คํ† ์ธ์ฝ”๋”๋Š” ์ง€๋„ ๋ฐ์ดํ„ฐ๊ฐ€ ํ•„์š” ์—†์œผ๋ฏ€๋กœ ๋น„์ง€๋„ ํ•™์Šต์ด๋‹ค. ์ž…๋ ฅ๊ณผ ์ถœ๋ ฅ์˜ ์ฐจ์ด๋ฅผ ์ด์šฉํ•ด ๋น„์ •์ƒ์ ์ธ ..
nvidia-smi ์˜ต์…˜
ยท
๐Ÿ‘พ Deep Learning
- Full Support - All Tesla products, starting with the Kepler architecture - All Quadro products, starting with the Kepler architecture - All GRID products, starting with the Kepler architecture - GeForce Titan products, starting with the Kepler architecture - Limited Support - All Geforce products, starting with the Kepler architecture nvidia-smi [OPTION1 [ARG1]] [OPTION2 [ARG2]] ... -h, --help..
RNN์„ ์ด์šฉํ•œ ์ด๋ฏธ์ง€ ์ƒ์„ฑ(feat.MNIST)
ยท
๐Ÿ‘พ Deep Learning
RNN ํŠน์„ฑ์ƒ ์ธํ’‹ ๊ฐ’์„ ์‹œ๊ณ„์—ด๋กœ ๋‹ค๋ฃฌ๋‹ค. ๋”ฐ๋ผ์„œ ์ด๋ฏธ์ง€๋ฅผ ์ฒ˜๋ฆฌ ํ•  ๋•Œ ํ›ˆ๋ จ๋œ ๋ชจ๋ธ์— ์ฒ˜์Œ ๋ช‡ ํ–‰์„ ์ž…๋ ฅํ•˜๋ฉด ๋‹ค์Œ ํ–‰์„ ์˜ˆ์ธกํ•œ๋‹ค. ์ด ์˜ˆ์ธก๋œ ํ–‰์„ ํฌํ•จํ•ด ๋‹ค์‹œ ๋ช‡ ๊ฐœ์˜ ํ–‰์„ ์ž…๋ ฅ์œผ๋กœ ๋‹ค์Œ ํ–‰์„ ์˜ˆ์ธกํ•˜๋Š” ํ›ˆ๋ จ์„ ๋ฐ˜๋ณตํ•˜๋ฉด , ํ•ญ ํ–‰์”ฉ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑ ๊ฐ€๋Šฅํ•˜๋‹ค. # RNN #RNN์„ ์ด์šฉํ•œ ์ด๋ฏธ์ง€ ์ƒ์„ฑ import numpy as np import matplotlib.pyplot as plt from sklearn import datasets from sklearn.model_selection import train_test_split img_size = 8 # ์ด๋ฏธ์ง€์˜ ํญ๊ณผ ๋†’์ด n_time = 4 # ์‹œ๊ณ„์—ด ๋ฐ์ดํ„ฐ์˜ ์ˆ˜ n_in = img_size # ์ž…๋ ฅ์ธต์˜ ๋‰ด๋Ÿฐ ์ˆ˜ n_mid = 128 # ์€๋‹‰์ธต์˜ ๋‰ด๋Ÿฐ..
[DL] GRU (gated recurrent unit)
ยท
๐Ÿ‘พ Deep Learning
Gated Recurrent Unit LSTM์„ ๊ฐœ์„ ํ•œ ์ˆœํ™˜ ์‹ ๊ฒฝ๋ง์˜ ๊ฒŒ์ดํŠธ ๊ตฌ์กฐ 2014๋…„ ๋‰ด์š• ๋Œ€ํ•™๊ต์˜ ์กฐ๊ฒฝํ˜„ ๊ต์ˆ˜๋‹˜ ์™ธ 6์ธ์ด ์ตœ์ดˆ ์ œ์•ˆ ํ–ˆ๋‹ค. GRU๋Š” ์ž…๋ ฅ ๊ฒŒ์ดํŠธ์™€ ๋ง๊ฐ ๊ฒŒ์ดํŠธ๋ฅผ ํ•ฉํ•œ ์—…๋ฐ์ดํŠธ ๊ฒŒ์ดํŠธ๊ฐ€ ์žˆ๋‹ค. ๊ธฐ์–ต ์…€์—๋Š” ์ถœ๋ ฅ๊ฒŒ์ดํŠธ๊ฐ€ ์—†๋Š” ๋Œ€์‹  ๊ณผ๊ฑฐ์—์„œ ์ด์–ด๋ฐ›์€ ๊ธฐ์–ต์„ ์„ ๋ณ„ํ•˜๋Š” ๋ฆฌ์…‹ ๊ฒŒ์ดํŠธ๊ฐ€ ์žˆ๋‹ค. ์ด๋Ÿฌํ•œ ๊ฒŒ์ดํŠธ๊ฐ€ ๋™์ž‘ํ•ด LSTM์ฒ˜๋Ÿผ ์žฅ๊ธฐ ๊ธฐ์–ต์„ ์ด์–ด ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค. +: ์›์†Œ๊ฐ„์˜ ํ•ฉ x: ์›์†Œ๊ฐ„์˜ ๊ณฑ 1-: ์ „๋‹ฌ๋ฐ›์€ ๊ฐ’์„ 1์—์„œ ๋นผ๊ธฐ σ: ์‹œ๊ทธ๋ชจ์ด๋“œ ํ•จ์ˆ˜ r: ๋ฆฌ์…‹ ๊ฒŒ์ดํŠธ z: ์—…๋ฐ์ดํŠธ ๊ฒŒ์ดํŠธ h: ์ƒˆ๋กœ์šด ๊ธฐ์–ต x: t ์‹œ์ ์—์„œ ์‹ ๊ฒฝ๋ง์ธต์˜ ์ž…๋ ฅ h : t-1 ์ด์ „ ์‹œ์ ์˜ ์ถœ๋ ฅ ๊ฒŒ์ดํŠธ 2๊ฐœ์—๋Š” ๊ฐ๊ฐ ํ•™์Šต ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ€ ์žˆ๋‹ค. ๋˜ํ•œ tanh๋ฅผ ๋˜ ๋‹ค๋ฅธ ํ™œ์„ฑํ™” ํ•จ์ˆ˜๋กœ ์‚ฌ์šฉํ•˜๋Š” ํ•™์Šต ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ€ ์žˆ๋‹ค. ์ด..
๋‹คํ–ˆ๋‹ค
'๐Ÿ‘พ Deep Learning' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (8 Page)