https://busterworld.tistory.com/64
AUTOGRAD: 자동 미분
- 신경망의 중심인 autograd 패키지는 Tensor의 모든 연산에 대해 자동 미분을 제공함.
- 실행-기반-정의(define-by-run) 프레임워크
- 코드를 어떻게 작성하여 실행하느냐에 따라 역전파가 정의된다는 뜻이며, 역전파는 학습 과정의 매 단계마다 달라집니다.
Tensor
torch.Tensor 클래스
.requires_grad 속성을 True 로 설정하면 그 tensor에서 이뤄진 모든 연산들을 추적(track)하기 시작함.
.backward() 를 호출하여 모든 변화도(gradient)를 자동으로 계산
Tensor의 변화도는 .grad 속성에 누적됨.
.detach() 를 호출하여 연산 기록으로부터 분리(detach)하여 이후 연산들이 추적되는 것을 방지함.
기록을 추적하는 것(과 메모리를 사용하는 것)을 방지하기 위해, 코드 블럭을 with torch.no_grad(): 로 감쌀 수 있음.
Function 클래스
변화도(Gradient)
역전파.
out 은 하나의 스칼라 값만 갖고 있음.
out.backward() 는 out.backward(torch.tensor(1.)) 과 동일함.
https://pytorch.org/docs/stable/autograd.html#function
Automatic differentiation package - torch.autograd — PyTorch master documentation
Automatic differentiation package - torch.autograd torch.autograd provides classes and functions implementing automatic differentiation of arbitrary scalar valued functions. It requires minimal changes to the existing code - you only need to declare Tensor
pytorch.org
'2020 프로젝트 > Python tutorial 및 Gan competetion 도전기' 카테고리의 다른 글
예제로 배우는 파이토치(PYTORCH) (0) | 2019.09.17 |
---|---|
Pytorch로 딥러닝하기 : 60분만에 끝장내기 - 분류기(Classifier) 학습하기 (0) | 2019.09.17 |
Pytorch로 딥러닝하기 : 60분만에 끝장내기 - 신경망(Neural Networks) (0) | 2019.09.15 |
Pytorch로 딥러닝하기 : 60분만에 끝장내기 - PyTorch가 무엇인가요? (0) | 2019.09.15 |
생성적 적대 신경망(GANs)에 대한 초보자용 가이드 (GANs) (0) | 2019.09.14 |