torch Tensor.backward() Without this, the computation graph of the loss continues to accumulate. This is why we need to call backward() every time in Gradient Accumulation
Custom autograd
torch.autograd 에 대한 간단한 소개
torch.autograd 는 신경망 학습을 지원하는 PyTorch의 자동 미분 엔진입니다. 이 단원에서는 autograd가 신경망 학습을 어떻게 돕는지에 대한 개념적 이해를 할 수 있습니다. 배경(Background): 신경망(NN; Neural Network)은 어떤 입력 데이터에 대해 실행되는 중첩(nested)된 함수들의 모음(collection)입니다. 이 함수들은 PyTorch에서 Tensor로 저장되는, (가중치(weight)와 편향(bias)로 구성된) 매개변수들로 정의됩니다. 신경망을 학습하는 것은 2단계로 이...
https://tutorials.pytorch.kr/beginner/blitz/autograd_tutorial.html


Seonglae Cho