728x90
< VGGNet >
- Very Deep Convolutional Networks
- 논문에서는 오로지 깊이나 주는 영향력을 알기 위해 필터는 3x3으로 stride는 1로 고정했으며 MaxPooling은 2x2에 strdie 2로 하여 학습을 진행했다
- https://journeysnote.tistory.com/30?category=943336
[AIFFEL/FUNDAMENTALSTAGE/17] VGG-16 / ResNet
1. VGGNet - Very Deep Convolutional Networks - VGGNet은 ILSVRC 2014 준우승 (7.3% Top 5 Error) - Image Detection에서 망의 깊이(Depth)가 정확도에 주는 영향을 실험적으로 분석 - VGGNet에는 A, A-LRN,..
journeysnote.tistory.com
1. VGG 구조의 특징
- CNN 레이어 여러 개와 Max pooling 레이어 한 개로 이루어진다.
- CNN은 모두 커널 크기가 3X3 이라는 대표적인 특징을 가지고 있다
- 블록(구조를 모듈화 시켜 조금씩 바꾸어 쓸 수 있는 단위)에 따라 CNN레이어의 개수가 달라진다
- 블록의 마지막에는 항상 Max Pooling레이어가 붙는다
VGG 기본 블록 하나
def build_vgg_block(input_layer,
num_cnn=3,
channel=64,
block_num=1,
):
# 입력 레이어
x = input_layer
# CNN 레이어
for cnn_num in range(num_cnn):
x = keras.layers.Conv2D(
filters=channel,
kernel_size=(3,3),
activation='relu',
kernel_initializer='he_normal',
padding='same',
name=f'block{block_num}_conv{cnn_num}'
)(x)
# Max Pooling 레이어
x = keras.layers.MaxPooling2D(
pool_size=(2, 2),
strides=2,
name=f'block{block_num}_pooling'
)(x)
return x
VGG-16
def build_vgg(input_shape=(32,32,3),
num_cnn_list=[2,2,3,3,3],
channel_list=[64,128,256,512,512],
num_classes=10):
assert len(num_cnn_list) == len(channel_list) #모델을 만들기 전에 config list들이 같은 길이인지 확인합니다.
input_layer = keras.layers.Input(shape=input_shape) # input layer를 만들어둡니다.
output = input_layer
# config list들의 길이만큼 반복해서 블록을 생성합니다.
for i, (num_cnn, channel) in enumerate(zip(num_cnn_list, channel_list)):
output = build_vgg_block(
output,
num_cnn=num_cnn,
channel=channel,
block_num=i
)
output = keras.layers.Flatten(name='flatten')(output)
output = keras.layers.Dense(4096, activation='relu', name='fc1')(output)
output = keras.layers.Dense(4096, activation='relu', name='fc2')(output)
output = keras.layers.Dense(num_classes, activation='softmax', name='predictions')(output)
model = keras.Model(
inputs=input_layer,
outputs=output
)
return model
- num_classes 는 데이터를 CIFAR-10을 이용했기 때문에 10.
VGG-19
vgg_19 = build_vgg(
num_cnn_list = [2,2,4,4,4],
channel_list = [64,128,256,512,512]
)
'AIFFEL > GoingDeeper-CV' 카테고리의 다른 글
[AIFFEL/GoingDeeper] OCR - Text recognition (0) | 2022.04.13 |
---|---|
[AIFFEL/GoingDeeper] OCR - Text detection (0) | 2022.04.13 |
[AIFFEL/GoingDeeper] Cutmix & Mixup Augmentation (0) | 2022.03.29 |
[AIFFEL/GoingDeeper] ResNet-34와 ResNet-50 Tensorflow 구현하기 (0) | 2022.03.25 |
[AIFFEL/GoingDeeper] Data Augmentation(데이터 증강) (0) | 2022.03.21 |