728x90 ๋ฐ์ํ Deep Learning/[์ฝ๋ ๊ตฌํ] DL Architecture ๊ตฌํ3 [Transformer] train.py, dataset.py, config.py, Mask ๊ตฌํํ๊ธฐ - 2 (Pytorch) ์ง๋ ์๊ฐ์ ์ด์ด, ์ค๋์ ๋๋จธ์ง train.py, config.py, dataset.py ํ์ผ์ ๊ตฌํํ๋ค. https://www.youtube.com/watch?v=ISNdQcPhsts ์ด ๋ถ ์ฝ๋๋ฅผ ๋ฐํ์ผ๋ก ๊ตฌํํ์์ต๋๋ค. 1. Dataset.py ๊ตฌํ 1-1. Bilingual Dataset ์ฌ์ฉํ ๋ฐ์ดํฐ์ ์ Hugging Face์์ ์ ๊ณตํ๋ opus_books Dataset์ ํ์ฉํ์๋ค. https://huggingface.co/datasets/opus_books/viewer/en-it opus_books · Datasets at Hugging Face { "en": "Nor could I pass unnoticed the suggestion of the bleak shores of Laplan.. 2024. 2. 21. [Transformer] ์ํคํ ์ฒ ๊ตฌํํ๊ธฐ - 1 (Pytorch) Transformer๋ ๋ ผ๋ฌธ์ผ๋ก๋ง ์ฝ์ด๋ดค์ง, ์ฝ๋๋ก ๋ฏ์ด๋ณด๋ ๊ฒ์ ์ฒ์์ด๋ค. ๋ ผ๋ฌธ ์ ์๋ค์ ์ ๋ง ์ฒ์ฌ๊ฐ ๋ง๋ ๊ฒ ๊ฐ๋ค. ์ ํ๋ธ๋ฅผ ์ฐธ๊ณ ํด์ ์ฝ๋๋ฅผ ๊ตฌํํ์์ผ๋ฉฐ, ์ด๋ฒ ํฌ์คํ ์ ์ค๋ก์ง ์ํคํ ์ฒ์๋ง ์ด์ ์ ๋ง์ท๋ค. ๋ฐ์ดํฐ ๋ถ๋ถ์ ๋ค์์ฃผ์ ์ฌ๋ฆด ์์ . 1. Input Embedding ๊ตฌํํ๊ธฐ import torch import torch.nn as nn import math #Input embedding class InputEmbeddings(nn.Module): #d ์ฐจ์ ์ค์ , vocab size ์ค์ (์ผ๋ง๋ ๋ง์ ๋จ์ด ๋ฃ์๊ฑด์ง) def __init__(self,d_model : int, vocab_size : int): super().__init__() self.d_model = d_model self... 2024. 2. 17. [UNet] copy and crop ์ฝ๋ ๊ตฌํ ๋ฐ ์ํคํ ์ฒ ๊ตฌํํ๊ธฐ (Pytorch) ๋ค๋ฅธ ๋ธ๋ก๊ทธ๋ค์์๋ padding์ 2๋ก ๋ง์ถฐ์, ๋ฐ๋ก copy and crop์ ํ์ง ์์์ง๋ง, ํด๋น ๋ ผ๋ฌธ์ ๊ทธ๋ฆผ์ ๋ณด๊ณ ์ฌํํ๊ธฐ ์ํด padding=0์ผ๋ก ์ค์ ํด์ ๋ณธ ์ํคํ ์ฒ๋ฅผ ์๋ก ๊ตฌ์ถํ์๋ค. import torch.nn as nn import torch.nn.functional as F import torch import os import numpy as np from torchvision import transforms #https://sd118687.tistory.com/8 (Mirroring extrapolate) class UNet(nn.Module): #copy and crop ํจ์ ์ ์ #batch_size, channels, height, width def copy_and_crop(.. 2024. 2. 8. ์ด์ 1 ๋ค์ 728x90 ๋ฐ์ํ