torch

    torchvision.transforms (ToTensor, Normalize, Resize, RandomCrop,Compose)

    transforms ๋ชจ๋“ˆ์€ ์ด๋ฏธ์ง€๋ฅผ ํ•™์Šต์„ ์œ„ํ•ด ์ ์ ˆํžˆ ๋ณ€ํ™˜ํ• ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋ชจ๋“ˆ์—์„œ ์ฃผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ์†Œ๊ฐœํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. module import import torchvision.transforms as transforms transforms.ToTensor transforms.ToTensor() Pytorch์˜ ๋ฐฐ์—ด์€ ๋ฐฐ์—ด๊ตฌ์กฐ๊ฐ€ C*H*W(C:์ฑ„๋„, H:๋†’์ด, W:๋„ˆ๋น„)์ž…๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ PIL์ด๋ฏธ์ง€์™€ Numpy ๋ฐฐ์—ด์—์„œ๋Š” H*W*C์ž…๋‹ˆ๋‹ค. ToTensor๋Š” ์ด๋Ÿฌํ•œ ๋ฐ์ดํ„ฐ์˜ ๊ตฌ์กฐ๋ฅผ ๋ณ€๊ฒฝํ•ด์ค๋‹ˆ๋‹ค. ๋˜ํ•œ ToTensor๋Š” ์ด๋ฏธ์ง€ ํ”ฝ์…€์˜ ๋ฐ๊ธฐ์ •๋„๋ฅผ Scaleํ•ด์ค๋‹ˆ๋‹ค. ๋ฐ๊ธฐ์ •๋„๊ฐ€ 0~255๋กœ ํ‘œ์‹œ๋˜์—ˆ๋‹ค๋ฉด ๊ทธ ๊ฐ’์„ 0~1๋กœ scaleํ•ด์ฃผ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. transforms.Nomalize transforms.Norma..