Autograd: 미분 자동화
- 원문: http://pytorch.org/tutorials/beginner/blitz/autograd_tutorial.html
- 원문 제목: Autograd: automatic differentiation?
PyTorch의 모든 신경 네트워크의 중심에는 autograd 패키지가 있습니다. 먼저 autograd에 대하여 간략히 살펴 보겠습니다. 그러나서 첫 번째 신경망을 훈련해 볼 것 입니다.
autograd
패키지는 오든 텐서 연산에 대해 미분 자동화 기능을 제공합니다. 실행 정의(define-by-run) 프레임웍입니다. 실행 정의란 역전파는 코드가 실행되는 방식에 이해 정이됨을 의미합니다. 모든 반복마다 달라질 수 있습니다.
몇 가지 예로 좀 더 간단한 용어를 살펴보겠습니다.
Variable
Gradients
NumPy 배열을 Torch 텐서로 변환
import numpy as np
a = np.ones(5)
b = torch.from_numpy(a)
np.add(a, 1, out=a)
print(a)
print(b)
출력:
[ 2. 2. 2. 2. 2.] 2 2 2 2 2 [torch.DoubleTensor of size 5]
CharTensor를 제외한 CPU에서 동작하는 모든 Tensor는 NumPy 변환과 NumPy로 부터의 Tensor 변환을 지원합니다.