๐Ÿ”ฅ PyTorch

๐Ÿ”ฅ PyTorch

[PyTorch] Checkpoint Model ์ €์žฅ & ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

โš ๏ธ ๋ณธ ๋‚ด์šฉ์€ PyTorch Korea์˜ ๊ณต์‹ ๋ฌธ์„œ์— ๊ธฐ๋ฐ˜ํ•˜์—ฌ ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์„ ์ ์€๊ฒƒ์ด๋‹ˆ ์–‘ํ•ด๋ฐ”๋ž๋‹ˆ๋‹ค! PyTorch์—์„œ ์ผ๋ฐ˜์ ์ธ ์ฒดํฌํฌ์ธํŠธ(checkpoint) ์ €์žฅํ•˜๊ธฐ & ๋ถˆ๋Ÿฌ์˜ค๊ธฐ์ถ”๋ก (inference) ๋˜๋Š” ํ•™์Šต(training)์˜ ์žฌ๊ฐœ๋ฅผ ์œ„ํ•ด ์ฒดํฌํฌ์ธํŠธ(checkpoint) ๋ชจ๋ธ์„ ์ €์žฅํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ค๋Š” ๊ฒƒ์€ ๋งˆ์ง€๋ง‰์œผ๋กœ ์ค‘๋‹จํ–ˆ๋˜ ๋ถ€๋ถ„์„ ์„ ํƒํ•˜๋Š”๋ฐ ๋„์›€์„ ์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฒดํฌํฌ์ธํŠธ๋ฅผ ์ €์žฅํ•  ๋•Œ๋Š”tutorials.pytorch.krPyTorch์—์„œ Inference & Training์„ ๋‹ค์‹œ ํ•˜๊ธฐ ์œ„ํ•ด์„œ Checkpoint Model์„ ์ €์žฅ & ๋ถˆ๋Ÿฌ์˜ค๋Š”๊ฒƒ์„ ํ•œ๋ฒˆ ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.IntroPyTorch์—์„œ ์—ฌ๋Ÿฌ Checkpoint๋“ค์„ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•ด์„  ์‚ฌ์ „(Dictionary)์— Checkpoint๋“ค์„ ๊ตฌ์„ฑํ•œํ›„..

๐Ÿ”ฅ PyTorch

[PyTorch] Model ์ €์žฅ & ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

โš ๏ธ ๋ณธ ๋‚ด์šฉ์€ PyTorch Korea์˜ ๊ณต์‹ ๋ฌธ์„œ์— ๊ธฐ๋ฐ˜ํ•˜์—ฌ ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์„ ์ ์€๊ฒƒ์ด๋‹ˆ ์–‘ํ•ด๋ฐ”๋ž๋‹ˆ๋‹ค! ๋ชจ๋ธ ์ €์žฅํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ค๊ธฐํŒŒ์ดํ† ์น˜(PyTorch) ๊ธฐ๋ณธ ์ตํžˆ๊ธฐ|| ๋น ๋ฅธ ์‹œ์ž‘|| ํ…์„œ(Tensor)|| Dataset๊ณผ Dataloader|| ๋ณ€ํ˜•(Transform)|| ์‹ ๊ฒฝ๋ง ๋ชจ๋ธ ๊ตฌ์„ฑํ•˜๊ธฐ|| Autograd|| ์ตœ์ ํ™”(Optimization)|| ๋ชจ๋ธ ์ €์žฅํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ค๊ธฐ ์ด๋ฒˆ ์žฅ์—์„œ๋Š” ์ €์žฅํ•˜๊ธฐ๋‚˜tutorials.pytorch.krModel ์ €์žฅํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ค๊ธฐ์ด๋ฒˆ์—๋Š” ์ €์žฅ or ๋ถˆ๋Ÿฌ์˜ค๊ธฐ๋ฅผ ํ†ตํ•ด ๋ชจ๋ธ์˜ ์ƒํƒœ ์œ ์ง€(persist)๋ฐ ๋ชจ๋ธ์˜ ์˜ˆ์ธก์„ ์‹œํ–‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.import torchimport torchvision.models as modelsModel Weight(๊ฐ€์ค‘์น˜) ์ €์žฅํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ค๊ธฐPyT..

๐Ÿ”ฅ PyTorch

[PyTorch] ๋ชจ๋ธ ๋งค๊ฐœ๋ณ€์ˆ˜ ์ตœ์ ํ™”(Optimization) ํ•˜๊ธฐ

โš ๏ธ ๋ณธ ๋‚ด์šฉ์€ PyTorch Korea์˜ ๊ณต์‹ ๋ฌธ์„œ์— ๊ธฐ๋ฐ˜ํ•˜์—ฌ ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์„ ์ ์€๊ฒƒ์ด๋‹ˆ ์–‘ํ•ด๋ฐ”๋ž๋‹ˆ๋‹ค! ๋ชจ๋ธ ๋งค๊ฐœ๋ณ€์ˆ˜ ์ตœ์ ํ™”ํ•˜๊ธฐํŒŒ์ดํ† ์น˜(PyTorch) ๊ธฐ๋ณธ ์ตํžˆ๊ธฐ|| ๋น ๋ฅธ ์‹œ์ž‘|| ํ…์„œ(Tensor)|| Dataset๊ณผ Dataloader|| ๋ณ€ํ˜•(Transform)|| ์‹ ๊ฒฝ๋ง ๋ชจ๋ธ ๊ตฌ์„ฑํ•˜๊ธฐ|| Autograd|| ์ตœ์ ํ™”(Optimization)|| ๋ชจ๋ธ ์ €์žฅํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ค๊ธฐ ์ด์ œ ๋ชจ๋ธ๊ณผ ๋ฐ์ดํ„ฐ๊ฐ€ ์ค€๋น„tutorials.pytorch.krModel ๋งค๊ฐœ๋ณ€์ˆ˜ ์ตœ์ ํ™” ํ•˜๊ธฐ์ด๋ฒˆ์—๋Š” ์ค€๋น„๋œ ๋ชจ๋ธ๊ณผ ๋ฐ์ดํ„ฐ๋กœ, ๋ฐ์ดํ„ฐ์— ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์ตœ์ ํ™” ํ•˜์—ฌ ๋ชจ๋ธ์„ ํ•™์Šต, ๊ฒ€์ฆ, ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.๋ชจ๋ธ์„ ํ•™์Šตํ•˜๋Š” ๊ณผ์ •์€ ๋ฐ˜๋ณต์ ์ธ ๊ณผ์ •์„ ๊ฑฐ์นฉ๋‹ˆ๋‹ค.๊ฐ ๋ฐ˜๋ณต ๋‹จ๊ณ„์—์„œ ๋ชจ๋ธ์€ ์ถœ๋ ฅ์„ ์ถ”์ธกํ•˜๊ณ , ์ถ”์ธก๊ณผ ์ •๋‹ต ์‚ฌ์ด์˜ ์˜ค๋ฅ˜(์†์‹ค(loss))๋ฅผ..

๐Ÿ”ฅ PyTorch

[PyTorch] Torch.Autograd๋ฅผ ์ด์šฉํ•œ ์ž๋™ ๋ฏธ๋ถ„

โš ๏ธ ๋ณธ ๋‚ด์šฉ์€ PyTorch Korea์˜ ๊ณต์‹ ๋ฌธ์„œ์— ๊ธฐ๋ฐ˜ํ•˜์—ฌ ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์„ ์ ์€๊ฒƒ์ด๋‹ˆ ์–‘ํ•ด๋ฐ”๋ž๋‹ˆ๋‹ค! torch.autograd๋ฅผ ์‚ฌ์šฉํ•œ ์ž๋™ ๋ฏธ๋ถ„ํŒŒ์ดํ† ์น˜(PyTorch) ๊ธฐ๋ณธ ์ตํžˆ๊ธฐ|| ๋น ๋ฅธ ์‹œ์ž‘|| ํ…์„œ(Tensor)|| Dataset๊ณผ Dataloader|| ๋ณ€ํ˜•(Transform)|| ์‹ ๊ฒฝ๋ง ๋ชจ๋ธ ๊ตฌ์„ฑํ•˜๊ธฐ|| Autograd|| ์ตœ์ ํ™”(Optimization)|| ๋ชจ๋ธ ์ €์žฅํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ค๊ธฐ ์‹ ๊ฒฝ๋ง์„ ํ•™์Šตํ•  ๋•Œ ๊ฐ€์žฅtutorials.pytorch.kr torch.autograd๋ฅผ ์‚ฌ์šฉํ•œ ์ž๋™ ๋ฏธ๋ถ„์ผ๋ฐ˜์ ์œผ๋กœ Neural Network(์‹ ๊ฒฝ๋ง)์„ ํ•™์Šตํ•  ๋–„ ๊ฐ€์žฅ ์ž์ฃผ ์‚ฌ์šฉ๋˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ Backpropagation(์—ญ์ „ํŒŒ)์ž…๋‹ˆ๋‹ค.์ด ์•Œ๊ณ ๋ฆฌ์ฆ˜์—์„œ, ๋งค๊ฐœ๋ณ€์ˆ˜(๋ชจ๋ธ ๊ฐ€์ค‘์น˜)๋Š” ์ฃผ์–ด์ง„ ๋งค๊ฐœ๋ณ€์ˆ˜์— ๋Œ€ํ•œ ์†์‹ค ํ•จ์ˆ˜..

๐Ÿ”ฅ PyTorch

[PyTorch] Neural Network Model (์‹ ๊ฒฝ๋ง ๋ชจ๋ธ) ๊ตฌ์„ฑํ•˜๊ธฐ

โš ๏ธ ๋ณธ ๋‚ด์šฉ์€ PyTorch Korea์˜ ๊ณต์‹ ๋ฌธ์„œ์— ๊ธฐ๋ฐ˜ํ•˜์—ฌ ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์„ ์ ์€๊ฒƒ์ด๋‹ˆ ์–‘ํ•ด๋ฐ”๋ž๋‹ˆ๋‹ค! ์‹ ๊ฒฝ๋ง ๋ชจ๋ธ ๊ตฌ์„ฑํ•˜๊ธฐํŒŒ์ดํ† ์น˜(PyTorch) ๊ธฐ๋ณธ ์ตํžˆ๊ธฐ|| ๋น ๋ฅธ ์‹œ์ž‘|| ํ…์„œ(Tensor)|| Dataset๊ณผ Dataloader|| ๋ณ€ํ˜•(Transform)|| ์‹ ๊ฒฝ๋ง ๋ชจ๋ธ ๊ตฌ์„ฑํ•˜๊ธฐ|| Autograd|| ์ตœ์ ํ™”(Optimization)|| ๋ชจ๋ธ ์ €์žฅํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ค๊ธฐ ์‹ ๊ฒฝ๋ง์€ ๋ฐ์ดํ„ฐ์— ๋Œ€ํ•œ ์—ฐtutorials.pytorch.krNeural Network Model (์‹ ๊ฒฝ๋ง ๋ชจ๋ธ) ๊ตฌ์„ฑํ•˜๊ธฐ์‹ ๊ฒฝ๋ง์€ ๋ฐ์ดํ„ฐ์— ๋Œ€ํ•œ ์—ฐ์‚ฐ์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ณ„์ธต(layer)/๋ชจ๋“ˆ(module)๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.torch.nn ๋„ค์ž„์ŠคํŽ˜์ด์Šค๋Š” ์‹ ๊ฒฝ๋ง์„ ๊ตฌ์„ฑํ•˜๋Š”๋ฐ ํ•„์š”ํ•œ ๋ชจ๋“  ๊ตฌ์„ฑ ์š”์†Œ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. PyTorch์˜ ๋ชจ๋“  ๋ชจ๋“ˆ์€ nn..

๐Ÿ”ฅ PyTorch

[PyTorch] Transform (๋ณ€ํ˜•)

โš ๏ธ ๋ณธ ๋‚ด์šฉ์€ PyTorch Korea์˜ ๊ณต์‹ ๋ฌธ์„œ์— ๊ธฐ๋ฐ˜ํ•˜์—ฌ ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์„ ์ ์€๊ฒƒ์ด๋‹ˆ ์–‘ํ•ด๋ฐ”๋ž๋‹ˆ๋‹ค! ๋ณ€ํ˜•(Transform)ํŒŒ์ดํ† ์น˜(PyTorch) ๊ธฐ๋ณธ ์ตํžˆ๊ธฐ|| ๋น ๋ฅธ ์‹œ์ž‘|| ํ…์„œ(Tensor)|| Dataset๊ณผ Dataloader|| ๋ณ€ํ˜•(Transform)|| ์‹ ๊ฒฝ๋ง ๋ชจ๋ธ ๊ตฌ์„ฑํ•˜๊ธฐ|| Autograd|| ์ตœ์ ํ™”(Optimization)|| ๋ชจ๋ธ ์ €์žฅํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ค๊ธฐ ๋ฐ์ดํ„ฐ๊ฐ€ ํ•ญ์ƒ ๋จธ์‹ ๋Ÿฌ๋‹ ์•Œtutorials.pytorch.krTransform (๋ณ€ํ˜•)๋ฐ์ดํ„ฐ ๋ณ€ํ˜•(Transform)์€ ๋ฐ์ดํ„ฐ ์ „์ฒ˜๋ฆฌ ๋ฐ ๋ฐ์ดํ„ฐ ์ฆ๊ฐ•(data augmentation)์„ ์œ„ํ•ด ์ž์ฃผ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.๋ฐ์ดํ„ฐ๊ฐ€ ํ•ญ์ƒ ๋จธ์‹ ๋Ÿฌ๋‹ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ํ•™์Šต์— ํ•„์š”ํ•œ ์ตœ์ข… ์ฒ˜๋ฆฌ๊ฐ€ ๋œ ํ˜•ํƒœ๋กœ ์ œ๊ณต๋˜์ง€๋Š” ์•Š์Šต๋‹ˆ๋‹ค.๋ณ€ํ˜•(transform) ์„ ํ•ด์„œ ๋ฐ์ด..

๐Ÿ”ฅ PyTorch

[PyTorch] Dataset & DataLoader with CIFAR-10

โš ๏ธ ๋ณธ ๋‚ด์šฉ์€ PyTorch Korea์˜ ๊ณต์‹ ๋ฌธ์„œ์— ๊ธฐ๋ฐ˜ํ•˜์—ฌ ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์„ ์ ์€๊ฒƒ์ด๋‹ˆ ์–‘ํ•ด๋ฐ”๋ž๋‹ˆ๋‹ค! Dataset๊ณผ DataLoaderํŒŒ์ดํ† ์น˜(PyTorch) ๊ธฐ๋ณธ ์ตํžˆ๊ธฐ|| ๋น ๋ฅธ ์‹œ์ž‘|| ํ…์„œ(Tensor)|| Dataset๊ณผ DataLoader|| ๋ณ€ํ˜•(Transform)|| ์‹ ๊ฒฝ๋ง ๋ชจ๋ธ ๊ตฌ์„ฑํ•˜๊ธฐ|| Autograd|| ์ตœ์ ํ™”(Optimization)|| ๋ชจ๋ธ ์ €์žฅํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ค๊ธฐ ๋ฐ์ดํ„ฐ ์ƒ˜ํ”Œ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์ฝ”tutorials.pytorch.krDataset & DataLoaderPyTorch์˜ Dataset๊ณผ DataLoader๋Š” ๋ฐ์ดํ„ฐ์…‹์„ ํšจ์œจ์ ์œผ๋กœ ๋กœ๋“œํ•˜๊ณ  ์ „์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋˜๋Š” ๊ฐ•๋ ฅํ•œ ๋„๊ตฌ์ž…๋‹ˆ๋‹ค.๋Œ€๊ทœ๋ชจ ๋ฐ์ดํ„ฐ์…‹์„ ๋ฐฐ์น˜ ๋‹จ์œ„๋กœ ๋‚˜๋ˆ„์–ด ๋ชจ๋ธ์— ๊ณต๊ธ‰ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ค๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ ์ƒ˜ํ”Œ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์ฝ”..

๐Ÿ”ฅ PyTorch

[PyTorch] PyTorch Intro & Tensor (ํ…์„œ)

โš ๏ธ ๋ณธ ๋‚ด์šฉ์€ PyTorch Korea์˜ ๊ณต์‹ ๋ฌธ์„œ์— ๊ธฐ๋ฐ˜ํ•˜์—ฌ ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์„ ์ ์€๊ฒƒ์ด๋‹ˆ ์–‘ํ•ด๋ฐ”๋ž๋‹ˆ๋‹ค! ํ…์„œ(Tensor)ํŒŒ์ดํ† ์น˜(PyTorch) ๊ธฐ๋ณธ ์ตํžˆ๊ธฐ|| ๋น ๋ฅธ ์‹œ์ž‘|| ํ…์„œ(Tensor)|| Dataset๊ณผ Dataloader|| ๋ณ€ํ˜•(Transform)|| ์‹ ๊ฒฝ๋ง ๋ชจ๋ธ ๊ตฌ์„ฑํ•˜๊ธฐ|| Autograd|| ์ตœ์ ํ™”(Optimization)|| ๋ชจ๋ธ ์ €์žฅํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ค๊ธฐ ํ…์„œ(tensor)๋Š” ๋ฐฐ์—ด(array)์ดtutorials.pytorch.krPyTorch (ํŒŒ์ดํ† ์น˜)PyTorch๋Š” Facebook's AI Research (FAIR) ํŒ€์— ์˜ํ•ด ๊ฐœ๋ฐœ๋œ ์˜คํ”ˆ ์†Œ์Šค ๋”ฅ๋Ÿฌ๋‹ ํ”„๋ ˆ์ž„์›Œํฌ ์ž…๋‹ˆ๋‹ค.PyTorch๋Š” ๋น ๋ฅด๊ณ  ์œ ์—ฐํ•œ ํ”„๋กœํ† ํƒ€์ดํ•‘์„ ์ง€์›ํ•˜๋ฉฐ, ๋‹ค์–‘ํ•œ ์—ฐ๊ตฌ ๋ฐ ์‚ฐ์—… ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์— ๋„๋ฆฌ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.PyTo..

Bigbread1129
'๐Ÿ”ฅ PyTorch' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก