autograd
![[PyTorch] RuntimeError: Trying to backward through the graph a second time](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fndi8x%2Fbtq3n8HufQ5%2Fy6e9QI3KEnaHifzCt2zNf0%2Fimg.png)
[PyTorch] RuntimeError: Trying to backward through the graph a second time
Introduction 파이토치를 이용해 다양한 모델을 구현하다 보면, 아래와 같은 에러 메시지를 한번 쯤은 마주할 것이다. RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time 오늘은 이 에러 메시지가 어떤 상황에서, 어떤 이유로 출력되는 지 알아보고, 그 해결 방법에 대해 간략히 설명할 예정이다. Autograd Mechanism 기본적으로 파이토치의 autograd 메커니즘은 requires_grad=True 로 설정된 텐서들에 대해, 텐서 데이터가 생..