컨볼루션 신경망 (CNN)을 사용하여 이미지 콘텐츠에서 더욱 높은 수준의 표현을 점진적으로 추출할 수 있다는 사실이 발견되자 이미지 분류용 모델 개발에는 획기적인 변화가 일어났습니다. 질감이나 모양과 같은 특성을 추출하기 위해 데이터를 사전 처리할 필요 없이, CNN을 이용하면 이미지의 원시 픽셀 데이터를 입력값으로 사용할 수 있습니다. 그러면 CNN이 이러한 특성을 추출하는 방법을 '학습'하고 특성들로 구성된 개체가 무엇인지 추론합니다.
먼저 CNN은 입력 특성 맵을 받습니다. 이 맵은 3차원 행렬로, 처음 2차원의 크기가 픽셀로 표시한 이미지의 길이 및 너비에 대응됩니다. 세 번째 차원의 크기는 3이며, 이는 빨강, 녹색, 파랑 등 컬러 이미지의 채널 3개에 해당합니다. CNN은 각각 세 가지의 작업을 맡는 여러 개의 모듈로 구성되어 있습니다.
1. 컨볼루션
컨볼루션은 입력 특성 맵의 타일을 추출한 다음 이 타일에 필터를 적용하여 새로운 특성을 산출합니다. 그 결과 생성된 출력 특성 맵, 즉 합성곱된 특성은 입력 특성 맵과 크기 및 깊이가 달라질 수 있습니다. 컨볼루션은 다음과 같은 두 개의 매개변수로 정의됩니다.
추출되는 타일의 크기 (일반적으로 3x3 또는 5x5픽셀)
출력 특성 맵의 깊이, 적용되는 필터 수와 대응됨
컨볼루션 단계에서는 타일 크기와 동일한 크기의 행렬인 필터가 입력 특성 맵의 그리드를 한 번에 한 픽셀씩 가로 및 세로 방향으로 이동하면서 해당하는 타일을 추출합니다(그림 3 참고).
그림 3. 5x5 입력 특성 맵(깊이 1)에 3x3 컨볼루션(깊이 1) 단계가 진행되는 모습입니다. 5x5 특성 맵에서 3x3 타일을 추출할 수 있는 위치는 9개가 있으므로 컨볼루션 결과 3x3 출력 특성 맵이 생성됩니다.
CNN은 각 필터-타일 쌍마다 필터 행렬과 타일 행렬의 요소를 곱한 다음, 그 결과 생성된 행렬의 모든 요소를 더하여 하나의 값을 얻습니다. 모든 필터-타일 쌍에서 얻어진 값은 합성곱된 특성 행렬에 출력됩니다 (그림 4a 및 4b 참고).
그림 4a. 왼쪽: 5x5 입력 특성 맵 (깊이 1) 오른쪽: 3x3 컨볼루션 (깊이 1)
그림 4b. 왼쪽: 5x5 입력 특성 맵에 3x3 컨볼루션이 실행됩니다. 오른쪽: 컨볼루션 결과 생성된 합성곱된 특성입니다. 출력 지형지물 맵의 값을 클릭하면 계산 과정을 확인할 수 있습니다.
학습 단계에서 CNN은 입력 특성 맵에서 텍스처, 가장자리, 모양 등 유의미한 특성을 추출하는 데 가장 적합한 필터 행렬의 값이 어느 정도인지 '학습'하게 됩니다. 입력에 적용되는 필터 (출력 특성 맵의 깊이)의 수가 늘어날수록 CNN이 추출할 수 있는 특성의 수도 증가합니다. 하지만 CNN에서 소비하는 리소스의 대부분은 필터가 차지하므로 더 많은 필터가 추가될수록 학습 시간도 늘어납니다. 또한 신경망에 추가되는 각 필터는 이전 필터에 비해 늘어나는 가치가 적어지기 때문에, 엔지니어는 정확한 이미지 분류에 필요한 특성을 추출하는 데 최소한의 필터만 사용하는 신경망을 구축하는 것을 목표로 합니다.
2. ReLU
CNN은 모델에 비선형성을 주기 위해 컨볼루션 작업이 끝날 때마다 합성곱된 특성에 꺾인 선형 유닛(ReLU) 변형을 적용합니다. ReLU 함수 \(F(x)=max(0,x)\)는 x > 0인 모든 값에 대해 x를, x ≤ 0인 모든 값에 대해 0을 반환합니다.
3. 풀링
ReLU의 다음 단계는 풀링입니다. 이때 CNN은 처리 시간을 줄이기 위해 합성곱된 특성을 다운샘플링합니다. 즉, 가장 중요한 특성 정보는 남겨 두면서 특성 맵의 차원 수를 줄입니다. 이 과정에 일반적으로 사용되는 알고리즘을 최대 풀링이라고 합니다.
최대 풀링은 컨볼루션과 비슷한 방식으로 진행됩니다. 특성 맵을 이동하면서 지정된 크기의 타일을 추출하는 것입니다. 각 타일별로 최대값이 새로운 특성 맵에 출력되며 다른 모든 값은 버려집니다. 최대 풀링 작업에는 두 개의 매개변수가 사용됩니다.
최대 풀링 필터 크기 (일반적으로 2x2픽셀)
Stride: 추출된 타일을 분리하는 거리(픽셀 단위)입니다. 필터가 특성 맵을 픽셀 단위로 이동하는 컨볼루션과 다르게 최대 풀링에서는 스트라이드가 각 타일이 추출될 위치를 결정합니다. 2x2 필터의 경우 스트라이드가 2이면 최대 풀링 작업을 통해 특성 맵에서 중복되지 않는 모든 2x2 타일이 추출됩니다(그림 5 참고).
그림 5. 왼쪽: 4x4 특성 맵을 대상으로 2x2 필터와 스트라이드 2를 사용하여 최대 풀링이 진행되고 있습니다. 오른쪽: 최대 풀링 작업이 출력된 모습입니다. 작업 결과 생성된 특성 맵은 2x2 행렬이며, 각 타일에서 최대 값만 보존합니다.
완전 연결형 레이어
컨볼루션 신경망의 끝에는 하나 이상의 완전 연결형 레이어가 있습니다. 첫 번째 레이어에 있는 모든 노드가 두 번째 레이어의 모든 노드와 연결되었을 때 두 개의 레이어가 '완전히 연결'되었다고 합니다. 완전 연결형 레이어는 컨볼루션을 통해 추출된 특성을 기반으로 분류를 진행합니다. 일반적으로 최종 완전 연결형 레이어에는 소프트맥스 활성화 함수가 포함되어 있는데, 이 함수는 모델에서 예측하고자 하는 분류 라벨별로 0에서 1까지의 확률값을 출력합니다.
그림 6은 컨볼루션 신경망의 엔드 투 엔드 구조를 보여줍니다.
그림 6. 여기에 표시된 CNN은 특성 추출용 컨볼루션 모듈 2개 (컨볼루션 + ReLU + 풀링) 및 분류용 완전 연결형 레이어 2개를 갖추고 있습니다. 다른 CNN에는 컨볼루션 모듈이 더 많거나 적을 수도 있고 완전 연결형 레이어가 더 많거나 적을 수도 있습니다. 엔지니어들은 모델에서 최고의 결과를 산출하는 구성이 무엇인지 파악하기 위해 여러 가지 구성을 실험하곤 합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-27(UTC)"],[[["\u003cp\u003eConvolutional Neural Networks (CNNs) utilize convolutions to automatically learn and extract image features, eliminating the need for manual feature engineering.\u003c/p\u003e\n"],["\u003cp\u003eA CNN is comprised of convolutional, ReLU, and pooling layers for feature extraction, followed by fully connected layers for classification.\u003c/p\u003e\n"],["\u003cp\u003eDuring convolution, filters slide across the input image, extracting features like edges and textures which are then used for image classification.\u003c/p\u003e\n"],["\u003cp\u003eReLU introduces non-linearity to the model, while pooling downsamples the feature maps to reduce computational complexity while retaining important information.\u003c/p\u003e\n"],["\u003cp\u003eThe final fully connected layers classify the image based on the extracted features, often using a softmax activation function to output probabilities for each potential classification label.\u003c/p\u003e\n"]]],[],null,["# ML Practicum: Image Classification\n\nIntroducing Convolutional Neural Networks\n-----------------------------------------\n\nA breakthrough in building models for image classification came with the\ndiscovery that a [convolutional neural\nnetwork](https://wikipedia.org/wiki/Convolutional_neural_network) (CNN) could\nbe used to progressively extract higher- and higher-level representations of the\nimage content. Instead of preprocessing the data to derive features like\ntextures and shapes, a CNN takes just the image's raw pixel data as input and\n\"learns\" how to extract these features, and ultimately infer what object they\nconstitute.\n\nTo start, the CNN receives an input feature map: a three-dimensional matrix\nwhere the size of the first two dimensions corresponds to the length and width\nof the images in pixels. The size of the third dimension is 3 (corresponding to\nthe 3 channels of a color image: red, green, and blue). The CNN comprises a\nstack of modules, each of which performs three operations.\n\n### 1. Convolution\n\nA *convolution* extracts tiles of the input feature map, and applies filters to\nthem to compute new features, producing an output feature map, or *convolved\nfeature* (which may have a different size and depth than the input feature map).\nConvolutions are defined by two parameters:\n\n- **Size of the tiles that are extracted** (typically 3x3 or 5x5 pixels).\n- **The depth of the output feature map**, which corresponds to the number of filters that are applied.\n\nDuring a convolution, the filters (matrices the same size as the tile size)\neffectively slide over the input feature map's grid horizontally and vertically,\none pixel at a time, extracting each corresponding tile (see Figure 3).\n\n\n*Figure 3. A 3x3 convolution of depth 1 performed over a 5x5 input feature map,\nalso of depth 1. There are nine possible 3x3 locations to\nextract tiles from the 5x5 feature map, so this convolution produces a 3x3\noutput feature map.*\n| In Figure 3, the output feature map (3x3) is smaller than the input feature map (5x5). If you instead want the output feature map to have the same dimensions as the input feature map, you can add *padding* (blank rows/columns with all-zero values) to each side of the input feature map, producing a 7x7 matrix with 5x5 possible locations to extract a 3x3 tile.\n\nFor each filter-tile pair, the CNN performs element-wise multiplication of the\nfilter matrix and the tile matrix, and then sums all the elements of the\nresulting matrix to get a single value. Each of these resulting values for every\nfilter-tile pair is then output in the *convolved feature* matrix (see Figures\n4a and 4b).\n\n\n*Figure 4a. **Left** : A 5x5 input feature map (depth 1). **Right**: a 3x3\nconvolution (depth 1).*\n\n*Figure 4b. **Left** : The 3x3\nconvolution is performed on the 5x5 input feature map. **Right**: the\nresulting convolved feature. Click on a value in the output feature map to\nsee how it was calculated.*\n\nDuring training, the CNN \"learns\" the optimal values for the filter matrices\nthat enable it to extract meaningful features (textures, edges, shapes) from the\ninput feature map. As the number of filters (output feature map depth) applied\nto the input increases, so does the number of features the CNN can extract.\nHowever, the tradeoff is that filters compose the majority of resources expended\nby the CNN, so training time also increases as more filters are added.\nAdditionally, each filter added to the network provides less incremental value\nthan the previous one, so engineers aim to construct networks that use the\nminimum number of filters needed to extract the features necessary for accurate\nimage classification.\n\n### 2. ReLU\n\nFollowing each convolution operation, the CNN applies a Rectified Linear Unit\n(ReLU) transformation to the convolved feature, in order to introduce\nnonlinearity into the model. The ReLU function, \\\\(F(x)=max(0,x)\\\\), returns *x*\nfor all values of *x* \\\u003e 0, and returns 0 for all values of *x* ≤ 0.\n| ReLU is used as an activation function in a variety of neural networks; for more background, see [Introduction to Neural Networks](https://developers.google.com/machine-learning/crash-course/introduction-to-neural-networks/) in [Machine Learning\n| Crash Course](https://developers.google.com/machine-learning/crash-course/).\n\n### 3. Pooling\n\nAfter ReLU comes a pooling step, in which the CNN downsamples the convolved\nfeature (to save on processing time), reducing the number of dimensions of the\nfeature map, while still preserving the most critical feature information. A\ncommon algorithm used for this process is called [max\npooling](https://wikipedia.org/wiki/Convolutional_neural_network#Pooling_layer).\n\nMax pooling operates in a similar fashion to convolution. We slide over the\nfeature map and extract tiles of a specified size. For each tile, the maximum\nvalue is output to a new feature map, and all other values are discarded. Max\npooling operations take two parameters:\n\n- **Size** of the max-pooling filter (typically 2x2 pixels)\n- **Stride**: the distance, in pixels, separating each extracted tile. Unlike with convolution, where filters slide over the feature map pixel by pixel, in max pooling, the stride determines the locations where each tile is extracted. For a 2x2 filter, a stride of 2 specifies that the max pooling operation will extract all nonoverlapping 2x2 tiles from the feature map (see Figure 5).\n\n*Figure 5. **Left** : Max pooling performed over a 4x4\nfeature map with a 2x2 filter and stride of 2. **Right**: the output of the\nmax pooling operation. Note the resulting feature map is now 2x2, preserving\nonly the maximum values from each tile.*\n\n### Fully Connected Layers\n\nAt the end of a convolutional neural network are one or more fully connected\nlayers (when two layers are \"fully connected,\" every node in the first layer is\nconnected to every node in the second layer). Their job is to perform\nclassification based on the features extracted by the convolutions. Typically,\nthe final fully connected layer contains a softmax activation function, which\noutputs a probability value from 0 to 1 for each of the classification labels\nthe model is trying to predict.\n| For more on softmax and multi-class classification, see [Multi-Class Neural Networks](https://developers.google.com/machine-learning/crash-course/neural-networks/multi-class) in [Machine Learning\n| Crash Course](https://developers.google.com/machine-learning/crash-course/).\n\nFigure 6 illustrates the end-to-end structure of a convolutional neural network.\n\n*Figure 6. The CNN shown here contains two convolution modules (convolution + ReLU +\npooling) for feature extraction, and two fully connected layers for\nclassification. Other CNNs may contain larger or smaller numbers of\nconvolutional modules, and greater or fewer fully connected layers. Engineers\noften experiment to figure out the configuration that produces the best results\nfor their model.*\n| **Key Terms**\n|\n| |---------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|\n| | - [convolutional filter](/machine-learning/glossary#convolutional_filter) | - [convolutional neural network](/machine-learning/glossary#convolutional_neural_network) |\n| | - [convolutional operation](/machine-learning/glossary#convolutional_operation) | - [pooling](/machine-learning/glossary#pooling) |\n| | - [ReLU](/machine-learning/glossary#ReLU) | - [stride](/machine-learning/glossary#stride) |\n|"]]