반응형
블로그 이미지
개발자로서 현장에서 일하면서 새로 접하는 기술들이나 알게된 정보 등을 정리하기 위한 블로그입니다. 운 좋게 미국에서 큰 회사들의 프로젝트에서 컬설턴트로 일하고 있어서 새로운 기술들을 접할 기회가 많이 있습니다. 미국의 IT 프로젝트에서 사용되는 툴들에 대해 많은 분들과 정보를 공유하고 싶습니다.
솔웅

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리


반응형

8. Modern Convolutional Neural Networks — Dive into Deep Learning 1.0.0-beta0 documentation (d2l.ai)

 

8. Modern Convolutional Neural Networks — Dive into Deep Learning 1.0.0-beta0 documentation

 

d2l.ai

 

8. Modern Convolutional Neural Networks

 

Now that we understand the basics of wiring together CNNs, let’s take a tour of modern CNN architectures. This tour is, by necessity, incomplete, thanks to the plethora of exciting new designs being added. Their importance derives from the fact that not only can they be used directly for vision tasks, but they also serve as basic feature generators for more advanced tasks such as tracking (Zhang et al., 2021), segmentation (Long et al., 2015), object detection (Redmon and Farhadi, 2018), or style transformation (Gatys et al., 2016). In this chapter, most sections correspond to a significant CNN architecture that was at some point (or currently) the base model upon which many research projects and deployed systems were built. Each of these networks was briefly a dominant architecture and many were winners or runners-up in the ImageNet competition which has served as a barometer of progress on supervised learning in computer vision since 2010. It is only recently that Transformers have begun to displace CNNs, starting with Dosovitskiy et al. (2021) and followed by the Swin Transformer (Liu et al., 2021). We will cover this development later in the chapter on Attention Mechanisms and Transformers.

 

이제 CNN을 연결하는 기본 사항을 이해했으므로 최신 CNN 아키텍처를 살펴보겠습니다. 이 투어는 필요에 따라 불완전할 수 있습니다. 흥미진진한 새로운 디자인이 추가되고 있기 때문입니다. 그들의 중요성은 비전 작업에 직접 사용될 수 있을 뿐만 아니라 tracking (Zhang et al., 2021), segmentation  (Long et al., 2015), object detection(Redmon and Farhadi, 2018) 또는 style transformation(Gatys et al., 2016)과 같은 고급 작업을 위한 기본 기능 생성기 역할도 한다는 사실에서 비롯됩니다 . 이 장에서 대부분의 섹션은 특정 시점(또는 현재)에 많은 연구 프로젝트와 배포된 시스템이 구축된 기본 모델이었던 중요한 CNN 아키텍처에 해당합니다. 이러한 각 네트워크는 잠시 동안 지배적인 아키텍처였으며 2010년 이후 컴퓨터 비전에서 감독 학습의 진행 상황을 나타내는 척도 역할을 해 온 ImageNet 경쟁에서 많은 네트워크가 승자 또는 준우승자였습니다. 트랜스포머가 CNN을 대체하기 시작한 것은 최근의 일입니다. Dosovitskiy et al. (2021), Swin Transformer(Liu et al., 2021)가 그 뒤를 이었습니다. Attention Mechanisms and Transformers에 대한 장에서 나중에 이 개발을 다룰 것입니다.

 

While the idea of deep neural networks is quite simple (stack together a bunch of layers), performance can vary wildly across architectures and hyperparameter choices. The neural networks described in this chapter are the product of intuition, a few mathematical insights, and a lot of trial and error. We present these models in chronological order, partly to convey a sense of the history so that you can form your own intuitions about where the field is heading and perhaps develop your own architectures. For instance, batch normalization and residual connections described in this chapter have offered two popular ideas for training and designing deep models, both of which have since been applied to architectures beyond computer vision, too.

 

심층 신경망의 아이디어는 매우 간단하지만(여러 레이어를 함께 쌓음) 성능은 아키텍처와 하이퍼파라미터 선택에 따라 크게 다를 수 있습니다. 이 장에서 설명하는 신경망은 직관, 몇 가지 수학적 통찰, 그리고 많은 시행착오의 산물입니다. 우리는 이러한 모델을 연대순으로 제시하며 부분적으로는 역사 감각을 전달하여 해당 분야가 어디로 향하고 있는지에 대한 직관을 형성하고 아마도 자신만의 아키텍처를 개발할 수 있도록 합니다. 예를 들어, 이 장에서 설명하는 batch normalizationresidual connections은 딥 모델 훈련 및 설계에 대한 두 가지 인기 있는 아이디어를 제공했으며, 둘 다 이후 컴퓨터 비전을 넘어 아키텍처에도 적용되었습니다.

 

Batch Normalization 이란.

 

Batch Normalization is a technique used in Convolutional Neural Networks (CNNs) to normalize the activations of each layer during the training process. It aims to stabilize and improve the performance of the model by adjusting the distribution of input data within each mini-batch.

 

배치 정규화(Batch Normalization)는 합성곱 신경망(Convolutional Neural Networks, CNN)에서 사용되는 기법으로, 훈련 과정에서 각 층의 활성화를 정규화(normalize)하는 역할을 합니다. 이를 통해 모델의 안정성을 향상시키고 성능을 개선하기 위해 입력 데이터의 분포를 조정합니다.

 

The main idea behind Batch Normalization is to normalize the activation values of each layer. As the distribution of activation values may change throughout the layers, it can make training difficult and sensitive to hyperparameter tuning. Batch Normalization addresses this issue by normalizing the inputs of each layer using the mean and variance calculated within each mini-batch.

 

배치 정규화의 주요 아이디어는 각 층의 활성화 값을 정규화하는 것입니다. 각 층에서 활성화 값의 분포가 변할 수 있으므로 이는 훈련을 어렵게 하고 하이퍼파라미터 튜닝에 민감하게 만들 수 있습니다. 배치 정규화는 이러한 문제를 해결하기 위해 각 미니배치 내에서 입력 데이터의 평균과 분산을 계산하여 입력 데이터를 정규화합니다.

 

The normalization process in Batch Normalization involves calculating the mean and variance of the input data within each mini-batch. The input data is then normalized using these statistics. After normalization, the layer applies scale and shift parameters to the normalized inputs to compute the layer outputs. This helps to maintain a stable distribution of the input data across the layers, resulting in stabilized training and improved generalization performance.

 

배치 정규화의 정규화 과정은 각 미니배치 내에서 입력 데이터의 평균과 분산을 계산하는 단계로 이루어집니다. 그 후 입력 데이터는 이러한 통계치를 사용하여 정규화됩니다. 정규화된 입력에는 스케일과 쉬프트 파라미터가 적용되어 층의 출력을 계산합니다. 이를 통해 입력 데이터의 분포를 안정화하여 훈련 과정을 안정화시키고 일반화 성능을 향상시킵니다.

 

Batch Normalization offers several advantages in CNNs. It helps mitigate the issues of gradient vanishing and exploding that can occur during training. It improves the speed of convergence by reducing the internal covariate shift. It also reduces the sensitivity to hyperparameter tuning, making the network more robust.

 

배치 정규화는 CNN에서 여러 가지 이점을 제공합니다. 그레이디언트 소실과 폭주와 같은 문제를 완화시킵니다. 내부 공변량 이동(internal covariate shift)을 감소시켜 수렴 속도를 향상시킵니다. 또한 하이퍼파라미터 튜닝에 대한 민감성을 감소시켜 모델을 더 견고하게 만듭니다.

 

Batch Normalization is widely used in CNNs and has become an essential component for improving stability and performance in deep learning models.

 

배치 정규화는 CNN에서 널리 사용되며, 딥러닝 모델의 안정성과 성능 향상에 필수적인 구성 요소로 자리잡았습니다.

 

 

Residual Connections 란?

 

Residual Connections, also known as skip connections, are a technique used in Convolutional Neural Networks (CNNs) to address the vanishing gradient problem and enable the training of very deep networks.

 

Residual Connections(잔차 연결), 또는 스킵 연결,은 합성곱 신경망(CNN)에서 사용되는 기술로, 소실 그래디언트 문제(vanishing gradient problem)를 해결하고 매우 깊은 네트워크의 훈련을 가능하게 합니다.

 

In a standard CNN, each layer takes the output of the previous layer as input and applies a series of convolutional and activation operations. During training, gradients are backpropagated through the layers to update the network parameters. However, as the network gets deeper, the gradients can become very small, leading to the vanishing gradient problem. This makes it difficult for deep networks to learn and slows down the training process.

 

일반적인 CNN에서 각 층은 이전 층의 출력을 입력으로 받아 일련의 합성곱과 활성화 연산을 적용합니다. 훈련 중에는 그래디언트가 층을 통해 역전파되어 네트워크 매개변수를 업데이트합니다. 그러나 네트워크가 더 깊어질수록 그래디언트가 매우 작아지는 소실 그래디언트 문제가 발생할 수 있습니다. 이로 인해 깊은 네트워크가 학습하기 어려워지고 훈련 과정이 느려집니다.

 

Residual Connections aim to alleviate this problem by introducing skip connections that directly connect earlier layers to later layers. Instead of relying solely on the information flowing through the layers, residual connections allow the network to learn residual mappings. The output of a layer is added to the output of a previous layer, allowing the network to learn the difference or residual between these two outputs.

Mathematically, a residual connection can be represented as:

 

Residual Connections은 이 문제를 완화하기 위해 이전 층과 후속 층을 직접 연결하는 스킵 연결을 도입합니다. 층 사이를 통과하는 정보에만 의존하는 대신, 잔차 연결을 통해 네트워크는 잔차 매핑(residual mapping)을 학습할 수 있습니다. 층의 출력은 이전 층의 출력과 더해져 차이나 잔차를 학습하는 것입니다.

수학적으로 잔차 연결은 다음과 같이 표현될 수 있습니다:

output = input + F(input)

where input is the input to the layer, F(input) represents the transformation performed by the layer, and output is the combined output.

 

여기서 '입력'은 층에 주어진 입력, 'F(입력)'은 layer에 의해 수행된 변환, '출력'은 두 출력을 합친 것을 의미합니다.

 

By adding these residual connections, the network can effectively bypass and shortcut some of the layers. This helps in propagating gradients more easily and enables the network to learn deeper and more complex representations. It also allows the network to retain important information from earlier layers, even if subsequent layers try to modify or suppress it.

 

이러한 잔차 연결을 추가함으로써 네트워크는 일부 층을 우회하고 건너뛸 수 있습니다. 이를 통해 그래디언트를 보다 쉽게 전파할 수 있으며 네트워크가 더 깊고 복잡한 표현을 학습할 수 있게 됩니다. 또한 잔차 연결은 후속 층이 이를 수정하거나 억제하려고 할지라도 이전 층에서 중요한 정보를 보존할 수 있도록 도와줍니다.

 

Residual Connections have been shown to improve the training and performance of deep CNNs. They have been widely adopted in architectures like ResNet, where residual blocks are used to build very deep networks. These connections enable the successful training of models with hundreds or even thousands of layers and have contributed to significant advancements in computer vision tasks.

 

잔차 연결은 깊은 CNN의 훈련과 성능을 개선하는 데 도움이 됩니다. 잔차 블록(residual block)이 사용되는 ResNet과 같은 아키텍처에서 널리 채택되었습니다. 이러한 연결은 수백 개 또는 수천 개의 층을 가진 모델을 성공적으로 훈련할 수 있게 하며 컴퓨터 비전 작업에서의 중요한 발전에 기여하였습니다.

 

We begin our tour of modern CNNs with AlexNet (Krizhevsky et al., 2012), the first large-scale network deployed to beat conventional computer vision methods on a large-scale vision challenge; the VGG network (Simonyan and Zisserman, 2014), which makes use of a number of repeating blocks of elements; the network in network (NiN) that convolves whole neural networks patch-wise over inputs (Lin et al., 2013); GoogLeNet that uses networks with multi-branch convolutions (Szegedy et al., 2015); the residual network (ResNet) (He et al., 2016), which remains some of the most popular off-the-shelf architectures in computer vision; ResNeXt blocks (Xie et al., 2017) for sparser connections; and DenseNet (Huang et al., 2017) for a generalization of the residual architecture. Over time many special optimizations for efficient networks were developed, such as coordinate shifts (ShiftNet) (Wu et al., 2018). This culminated in the automatic search for efficient architectures such as MobileNet v3 (Howard et al., 2019). It also includes the semi-automatic design exploration of Radosavovic et al. (2020) that led to the RegNetX/Y which we will discuss later in this chapter. The work is instructive insofar as it offers a path to marry brute force computation with the ingenuity of an experimenter in the search for efficient design spaces. Of note is also the work of Liu et al. (2022) as it shows that training techniques (e.g., optimizers, data augmentation, and regularization) play a pivotal role in improving accuracy. It also shows that long-held assumptions, such as the size of a convolution window, may need to be revisited, given the increase in computation and data. We will cover this and many more questions in due course throughout this chapter.

 

우리는 대규모 비전 챌린지에서 기존의 컴퓨터 비전 방법을 능가하기 위해 배치된 최초의 대규모 네트워크인 AlexNet(Krizhevsky et al., 2012)으로 최신 CNN 투어를 시작합니다. VGG 네트워크(Simonyan and Zisserman, 2014)는 반복되는 여러 요소 블록을 사용합니다. 전체 신경망을 입력에 대해 패치 방식으로 컨볼루션하는 NiN(Network in Network)(Lin et al., 2013); 다중 분기 컨볼루션이 있는 네트워크를 사용하는 GoogLeNet(Szegedy et al., 2015); 잔여 네트워크(ResNet)(He et al., 2016)는 컴퓨터 비전에서 가장 인기 있는 기성품 아키텍처 중 일부로 남아 있습니다. 박한 연결을 위한 ResNeXt 블록(Xie et al., 2017); 잔차 아키텍처의 일반화를 위한 DenseNet(Huang et al., 2017) 등의 방법론들이 있습니다.

시간이 지남에 따라 좌표 이동(ShiftNet)과 같은 효율적인 네트워크를 위한 많은 특수 최적화가 개발되었습니다(Wu et al., 2018). 이는 MobileNet v3(Howard et al., 2019)와 같은 효율적인 아키텍처에 대한 자동 검색으로 절정에 달했습니다. 또한 Radosavovic et al.의 반자동 설계 탐색도 포함됩니다. (2020) 이 장의 뒷부분에서 논의할 RegNetX/Y로 이어졌습니다. 이 작업은 효율적인 설계 공간을 찾는 실험자의 독창성과 무차별 대입 계산을 결합하는 경로를 제공한다는 점에서 유익합니다. 주목할 만한 것은 Liu et al. (2022)는 학습 기술(예: 최적화 프로그램, 데이터 확대 및 정규화)이 정확도 향상에 중추적인 역할을 한다는 것을 보여줍니다. 또한 컨볼루션 창의 크기와 같은 오랜 가정을 계산 및 데이터의 증가로 인해 재검토해야 할 수도 있음을 보여줍니다. 우리는 이 장 전체에서 이 문제와 더 많은 질문을 다룰 것입니다.

 

 

https://youtu.be/iE4u8iu6Ioc

https://youtu.be/1Q_etC_GHHk

 

반응형