pytorch

    Pytorch Dataset๊ณผ DataLoader

    ํŒŒ์ดํ† ์น˜์—์„œ ๋ฐ์ดํ„ฐ๋“ค์„ ํ•™์Šตํ•  ๋•Œ ๊ต‰์žฅํžˆ ์œ ์šฉํ•œ ๊ธฐ๋Šฅ์œผ๋กœ DataLoader๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. DataLoader๋Š” ํŒŒ์ดํ† ์น˜์—์„œ ๋ฐ์ดํ„ฐ๋“ค์„ ์›ํ•˜๋Š” batch size๋กœ ์ž˜๋ผ์ค๋‹ˆ๋‹ค. DataLoader๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด batch size์— ๋งž์ถ”์–ด ํ•™์Šต์„ ๊ต‰์žฅํžˆ ์‰ฝ๊ฒŒ ํ•™์Šต์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๋•Œ DataLoader์— ๋„ฃ์–ด์ฃผ์–ด์•ผ ํ•˜๋Š” ๊ฐ’์ด Dataset์ด ๋ฉ๋‹ˆ๋‹ค. How To Use Dataset from torchvision import datasets, transforms train_dataset = datasets.MNIST( root = "data", download = True, train = True, transform = transforms.Compose([ transforms.ToTensor() ]..

    [Pytorch] nn.module์„ ์ƒ์†๋ฐ›์„ ๋•Œ super().__init__()์„ ํ•˜๋Š” ์ด์œ 

    [Pytorch] nn.module์„ ์ƒ์†๋ฐ›์„ ๋•Œ super().__init__()์„ ํ•˜๋Š” ์ด์œ 

    ํŒŒ์ดํ† ์น˜์—์„œ ํด๋ž˜์Šค๋กœ Layer๋‚˜ Model์„ ๊ตฌํ˜„ํ•ด์ฃผ๋ฉด ํ•ญ์ƒ ์ƒ์„ฑ์ž์—์„œ super(class์ด๋ฆ„, self).__init__()์„ ์ž…๋ ฅํ•ด์ค๋‹ˆ๋‹ค. ์™œ ์ด๊ฒƒ์„ ์ž…๋ ฅํ•ด์•ผ ํ•˜๋Š”์ง€ ๊ถ๊ธˆํ•˜์—ฌ ์•Œ์•„๋ณด์•˜์Šต๋‹ˆ๋‹ค. super().__init__()์ด ์—†๋‹ค๋ฉด? import torch class Test(torch.nn.Module): def __init__(self): self.linear = torch.nn.Linear(3,2) def forward(self,x): return self.linear(x) Test๋ฅผ ์œ„ํ•ด ๊ต‰์žฅํžˆ ๊ฐ„๋‹จํ•œ torch.nn.Module์„ ์ƒ์†๋ฐ›๋Š” ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์–ด๋ณด์•˜์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ด ํด๋ž˜์Šค๋ฅผ ํ™œ์šฉํ•ด ๋ชจ๋ธ์„ ๋งŒ๋“ค์–ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. model = Test() ์ƒ์„ฑ์„ ํ•˜๊ฒŒ ๋œ๋‹ค๋ฉด AttributeErro..