[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] ์ž…๋ ฅ๊ณผ ์ถœ๋ ฅ์˜ ํฌ๊ธฐ๋Š” ๊ฐ™๊ณ , ์€๋‹‰์ธต์˜ ํฌ๊ธฐ๋Š” ๊ทธ๋ณด๋‹ค ์ž‘๋‹ค. ์‹ ๊ฒฝ๋ง์€ ์ถœ๋ ฅ์—์„œ ์ž…๋ ฅํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ์žฌํ˜„ํ•˜๋„๋ก ํ•™์Šตํ•˜์ง€๋งŒ, ์€๋‹‰์ธต์˜ ํฌ๊ธฐ๋Š” ์ž…๋ ฅ๋ณด๋‹ค ์ž‘๋‹ค. ์ธ์ฝ”๋”๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์••์ถ•ํ•˜๊ณ  ๋””์ฝ”๋”๋กœ ์••์ถ•ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ์›๋ž˜ ๋ฐ์ดํ„ฐ๋กœ ๋ณต์›ํ•œ๋‹ค. ์ž…๋ ฅ ๋ฐ์ดํ„ฐ๊ฐ€ ์ด๋ฏธ์ง€๋ผ๋ฉด ์€๋‹‰์ธต์€ ์ธ์ฝ”๋”์™€ ๋””์ฝ”๋”๋ฅผ ์ด์šฉํ•ด ์›๋ž˜ ์ด๋ฏธ์ง€๋ณด๋‹ค ์ ์€ ๋ฐ์ดํ…จ ์–‘์œผ๋กœ ์ด๋ฏธ์ง€์˜ ํŠน์ง•์„ ์œ ์ง€ ํ•œ๋‹ค. ์ฆ‰ ์˜คํ† ์ธ์ฝ”๋”๋Š” ์‹ ๊ฒฝ๋ง์„ ์ด์šฉํ•œ ์ž…๋ ฅ์˜ ์••์ถ•๊ณผ ๋ณต์›์ด๋ผ๊ณ  ์ดํ•ดํ•˜๋ฉด ์‰ฝ๋‹ค. ์˜คํ† ์ธ์ฝ”๋”๋Š” ์ง€๋„ ๋ฐ์ดํ„ฐ๊ฐ€ ํ•„์š” ์—†์œผ๋ฏ€๋กœ ๋น„์ง€๋„ ํ•™์Šต์ด๋‹ค. ์ž…๋ ฅ๊ณผ ์ถœ๋ ฅ์˜ ์ฐจ์ด๋ฅผ ์ด์šฉํ•ด ๋น„์ •์ƒ์ ์ธ ..
์ž ์žฌ ๋””ํด๋ ˆ ํ• ๋‹น (LDiA, Latent Dirichlet Allocation)
ยท
๐Ÿ—ฃ๏ธ Natural Language Processing
LDiA ๋Œ€๋ถ€๋ถ„ ์ฃผ์ œ ๋ชจํ˜•ํ™”๋‚˜ ์˜๋ฏธ ๊ฒ€์ƒ‰, ๋‚ด์šฉ ๊ธฐ๋ฐ˜ ์ถ”์ฒœ ์—”์ง„์—์„œ ๊ฐ€์žฅ ๋จผ์ € ์„ ํƒํ•ด์•ผ ํ•  ๊ธฐ๋ฒ•์€ LSA์ด๋‹ค. ๋‚ด์šฉ ๊ธฐ๋ฐ˜ ์˜ํ™”์ถ”์ฒœ ์•Œ๊ณ ๋ฆฌ์ฆ˜์— ์˜ํ•˜๋ฉด LSA๊ฐ€ LDiA ๋ณด๋‹ค ์•ฝ ๋‘๋ฐฐ๋กœ ์ •ํ™•ํ•˜๋‹ค. LSA์— ๊น”๋ฆฐ ์ˆ˜ํ•™์€ ๊ฐ„๋‹จํ•˜๊ณ  ํšจ์œจ์ ์ด๋‹ค. NLP์˜ ๋งฅ๋ฝ์—์„œ LDiA๋Š” LSA์ฒ˜๋Ÿผ ํ•˜๋‚˜์˜ ์ฃผ์ œ ๋ชจํ˜•์„ ์‚ฐ์ถœํ•œ๋‹ค. LDiA๋Š” ์ด๋ฒˆ ์žฅ ๋„์ž…๋ถ€์—์„œ ํ–ˆ๋˜ ์‚ฌ๊ณ  ์‹คํ—˜๊ณผ ๋น„์Šทํ•œ ๋ฐฉ์‹์œผ๋กœ ์˜๋ฏธ ๋ฒกํ„ฐ ๊ณต๊ฐ„(์ฃผ์ œ ๋ฒกํ„ฐ๋“ค์˜ ๊ณต๊ฐ„)์„ ์‚ฐ์ถœํ•œ๋‹ค. LDiA๊ฐ€ LSA์™€ ๋‹ค๋ฅธ ์ ์€ ๋‹จ์–ด ๋นˆ๋„๋“ค์ด ๋””๋ฆฌํด๋ ˆ ๋ถ„ํฌ๋ฅผ ๋”ฐ๋ฅธ๋‹ค๊ณ  ๊ฐ€์ •ํ•œ๋‹ค. LSA์˜ ๋ชจํ˜•๋ณด๋‹ค LDiA์˜ ๋””๋ฆฌํด๋ ˆ ๋ถ„ํฌ๊ฐ€ ๋‹จ์–ด ๋นˆ๋„๋“ค์˜ ๋ถ„ํฌ๋ฅผ ์ž˜ ํ‘œํ˜„ํ•œ๋‹ค. LDiA๋Š” ์˜๋ฏธ ๋ฒกํ„ฐ ๊ณต๊ฐ„์„ ์‚ฐ์ถœํ•œ๋‹ค. ์‚ฌ๊ณ  ์‹คํ—˜์—์„œ ํŠน์ • ๋‹จ์–ด๋“ค์ด ๊ฐ™์€ ๋ฌธ์„œ์— ํ•จ๊ป˜ ๋“ฑ์žฅํ•˜๋Š” ํšŸ์ˆ˜์— ๊ธฐ์ดˆํ•ด์„œ ๋‹จ์–ด๋“ค์„ ์ฃผ์ œ๋“ค์— ์ง..
๋‹คํ–ˆ๋‹ค
B's