Residual connection은 대표적으로 컴퓨터 비전 분야에서의 ResNet 모델과 자연어 처리 분야에서의 transformer 모델에서 더 좋은 성능을 내기 위해 사용되었다. 간단히 말하자면, residual connection은 아주 deep한 신경망에서 하위 층에서 학습된 정보가 데이터 처리 과정에서 손실되는 것을 방지하기 위한 방법이다. '정보 소실'이란 무엇인지, 그리고 왜 일어나는지 이해하기 위해서는 신경망을 학습하는데 있어 고질적인 문제인 exploding gradient problem과 vanishing gradient problem에 대해 먼저 알아볼 필요가 있다.
Exploding gradient & Vanishing gradient problems
층이 많은 신경망에서 gradient problem이 일어나는 이유를 한 줄로 요약해보자면, 레이어가 많아질수록 weight value가 아주 작아지거나 아주 커지기 때문이다. 그리고 이러한 현상은 모델 파라미터가 최적해로 안정적으로 수렴하지 못하게 하는 원인이 된다.
신경망은 순전파(forward-propagation)와 역전파(back-propagation)을 반복하며 weight을 업데이트한다(자세한 내용은 [DL] 신경망의 개요 - ANN과 DNN (Neural Networks) 포스트 참고). Exploding gradient 문제를 설명하기에 앞서, hidden layer가 아주아주 많은 신경망을 상상해보자.


계산이 복잡해지니까 편향(bias)는 제외하고 하겠다. 그리고 활성화 함수
가 된다. 그 다음에 hidden layer의 활성화 함수를 거치면
마찬가지로 두 번째 hidden layer까지 거치면
이 된다. 보면 알지만 가중치 행렬을
이렇게
이 된다.
행렬의 원소

반대로 weight 행렬을 1보다 작은 수인 weight 행렬
가 되는데

Residual Connection
그럼 깊는 신경망은 어떻게 잘 학습시킬 수 있을까? Residual connection은 일부 레이어를 건너뛰어 데이터가 신경망 구조의 후반부에 도달하는 또 다른 경로를 제공함으로써 gradient가 계속 커지거나 작아지는 문제를 해결한다.
레이어


즉, 레이어
수백 개의 레이어가 있어도, residual block이 포함된 신경망은 경험적으로 훨씬 더 용이하게 수렴하는 것을 나타내고 있다(손실되거나 폭주하는 gradient값에 대한 보정으로 받아들이면 될듯... 맞나??). ResNet은 이전 모델인 VGG에 비해 더 많은 레이어를 가진 모델이고 이러한 방식이 성능 개선에 도움이 되었다고 한다.
How does it help training deep neural networks?
For feedforward neural networks, training a deep network is usually very difficult, due to problems such as exploding gradients and vanishing gradients. On the other hand, the training process of a neural network with residual connections is empirically shown to converge much more easily, even if the network has several hundreds layers. Like many techniques in deep learning, we still do not fully understand all the details about residual connection. However, we do have some interesting theories that are supported by strong experimental results.
Behaving Like Ensembles of Shallow Neural Networks
For feedforward neural networks, as we have mentioned above, the input will go through each layer of the network sequentially. More technically speaking, the input goes through a single path that has length equal to the number of layers. On the other hand, networks with residual connections consist of many paths of varying lengths.
- 출처 : https://towardsdatascience.com/what-is-residual-connection-efb07cab0d55
gradient problems에 대한 설명은 앤드류 응 교수님 강의 참고! 나 이분 없으면 공부못해...
'AI > Deep Learning' 카테고리의 다른 글
[DL] keyword extraction with KeyBERT - 개요 및 알고리즘 (0) | 2022.03.28 |
---|---|
[DL] Topic modeling with BERTopic - 개요 및 알고리즘 (0) | 2022.03.27 |
[DL] Transfer Learning vs Fine-tuning, 그리고 Pre-training (0) | 2022.03.17 |
[DL] 자연어 처리에서의 텍스트 표현 - 단어 임베딩(Word Embedding) (0) | 2022.03.11 |
[DL] 텍스트 데이터와 언어 모델(Language Model) (0) | 2022.03.10 |