Programming Error/PyTorch

[PyTorch Warning] W accumulate_grad.h:170 Warning: grad and param do not obey the gradient layout contract.

Barca 2021. 7. 13. 16:41

[W accumulate_grad.h:170] Warning: grad and param do not obey the gradient layout contract. This is not an error, but may impair performance. grad.sizes() = [64, 768, 1, 1], strides() = [768, 1, 1, 1] param.sizes() = [64, 768, 1, 1], strides() = [768, 1, 768, 768] (function operator())

 

PyTorch Framework로 모델을 학습하는 도중에 다음과 같은 Warning을 만났습니다.

Error는 아니고 Warning이라 넘어갈까했지만 may impair performance 성능을 저하시킬 수 있다는 문구가 거슬려 찾아보았습니다.

 

PyTorch Network를 구축할 때, Activation 계열에 inplace 옵션이 있는데 (ex. nn.ReLU(inplace=False)), 이를 예시와 같이 False로 명시할시에 위와같은 워닝이 발생하였습니다. 그래서 Docs를 찾아보니 inplace의 Defaul 옵션이 False인데, nn.ReLU()와 같이 사용했을 때는 왜 문제가 없는지 미궁속으로 빠지게 되었습니다...

 

어쨋든 명시적인 inplace=False를 제거해주시면 Warning이 없어진다입니다..

 

P.S. 추후 이유를 알게되면 수정하도록 하겠습니다~