본문 바로가기

pytorch tutorial

[Pytorch] MNIST 간단한 CNN 구현 및 정리 MNIST 간단한 CNN 구현 및 정리 모두의 딥러닝 시즌2 - Pytorch를 참고 했습니다. 모두의 딥러닝 시즌2 깃헙 import torch import torchvision.datasets as dsets import torchvision.transforms as transforms import torch.nn.init pytorch import device = 'cuda' if torch.cuda.is_available() else 'cpu' torch.manual_seed(777) if device == 'cuda': torch.cuda.manual_seed_all(123) device 설정(GPU or CPU) learning_rate = 0.001 training_epochs = 15 ba.. 더보기
[Pytorch tutorial] Autograd: 자동미분 본 포스팅은 파이토치 튜토리얼 한글판 홈페이지 바탕으로 작성하였습니다. pytorch tutorial - Autograd: 자동 미분 Autograd: 자동 미분 autograd 패키지는 tensor의 모든 연산에 대해 자동 미분을 제공 코드를 어떻게 작성하여 실행하느냐에 따라 역전파 정의됨(학습 과정의 매 단계마다 달라짐) Tensor .requires_grad=True로 설정하면 그 tensor에서 이뤄진 모든 연산들을 추적 계산 완료 후 .backward()를 호출하여 gradient 자동 계산 tensor의 변화도는 .grad 속성에 누적 .detach()를 호출하여 tensor가 기록을 추적하는 것을 방지 with torch.no_grad(): 로 코드 블럭을 감싸 기록 추적(메모리 사용) 방지.. 더보기
[Pytorch tutorial] PyTorch가 무엇인가요? 본 포스팅은 파이토치 튜토리얼 한글판 홈페이지 바탕으로 작성하였습니다. pytorch tutorial - pytorch가 무엇인가요? PyTorch가 무엇인가요? 파이썬 기반의 과학연산 패키지 Numpy를 대체하면서 GPU를 이용한 연산이 필요한 경우 최대한의 유연성과 속도를 제공하는 딥러닝 연구 플랫폼이 필요한 경우 Tensors 초기화 되지 않은 행렬 생성 x = torch.empty(5, 3) 무작위로 초기화된 행렬을 생성 x = torch.rand(5, 3) Returns a tensor filled with random numbers from a uniform distribution on the interval [0,1) 0 이상 1 미만의 수로 균등하게 초기화 dtype이 long이고 0으로 .. 더보기