라벨이 residual connection인 게시물 표시

[Model]PyTorch로 ResNet 구현하기

이미지
ResNet ResNet ¶ 탄생배경 model layer를 깊게 쌓을수록 성능이 증가, 하지만 gradient vanishing/exploding 문제가 발생하므로 특정 depth 이상 넘어갈수록 model의 성능이 급격히 하락. 이를 해결할 방안 존재? 해결 idea layer를 쌓을 때 적어도 그 전 layer의 성능보다 낮아지지 않도록 하는 방법 고안 방법론 새로운 layer를 쌓을 때, 새로운 layer의 output과 이전 layer의 output의 결과값을 더한다. 근거: 만약 해당 layer의 depth가 최적일 경우 역전파(backpropagation)에 의해 새로운 layer의 output이 0에 수렴할 것이므로 model의 성능이 떨어지지 않음. ref) With the residual learning reformulation, if identity mappings are optimal, the solvers may simply drive the weights of the multiple nonlinear layers toward zero to approach identity mappings. (paper page 3) # psudo code class residual_connection ( nn . Module ): def __init__ ( self ): self . block_1 = nn . Sequential () self . block_2 = nn . sequential () ... def forward ( self , x ): identity = x x = self . block_1 ( x ) x += identity # 만약 layer가 무리하게 쌓아졌다고 network가 판단할 경우 x -> 0 (by ba...