Convolution Layer's Output Size
- Output Size = (Intput Size + Padding Size * 2 - Convolution Size ) / Stride + 1
def calculate_convolution(input_size, input_chanel,
output_chanel, output_size=None,
conv_size=3, padding=1, stride =1,
print_input=True
):
if output_size == None:
output_size = (input_size + padding*2 - conv_size)/stride + 1
output_size = int(output_size) if output_size % 1 == 0 else False
if print_input:
print("[%sX%sX%s] Input"%(input_size,input_size,input_chanel))
print("[%sX%sX%s] CONV: %s %sX%s filters at stride %s, pad %s"%(
output_size,output_size,output_chanel,output_chanel,
conv_size,conv_size,stride,padding),
end="; "
)
print("params:(%s*%s*%s)*%s"%(input_chanel,conv_size,conv_size,output_chanel))
return output_size, output_chanel
calculate_convolution(input_size=29,input_chanel=3,output_chanel=20,
conv_size=5, padding=1, stride =2)
# [29X29X3] Input
# [14X14X20] CONV: 20 5X5 filters at stride 2, pad 1; params:(3*5*5)*20
# (14, 20)
Pooling Output Size
- Output Size = (Input Size - Pooling Size) / Stride + 1
def calculate_pooling(input_size=1,output_size=None, input_chanel="-",
pool_size=2, stride =1, print_input=True):
output_size = (input_size - pool_size)/stride + 1
output_size = int(output_size) if output_size % 1 == 0 else False
if print_input:
print("[%sX%sX%s] Input"%(input_size,input_size,input_chanel))
print("[%sX%sX%s] POOL: %sX%s filters at stride %s"%(
output_size, output_size,input_chanel,pool_size,pool_size,stride
))
return output_size, input_chanel
calculate_pooling(input_size=12,output_size=20, input_chanel=20,
pool_size=2, stride =2, print_input=True)
# [12X12X20] Input
# [6X6X20] POOL: 2X2 filters at stride 2
# (6, 20)
'DataScience > DeepLearning' 카테고리의 다른 글
[딥러닝 필기] week8. CNN Basics: CNN Structure (0) | 2022.04.16 |
---|---|
Transfer Learning 과 Fine Tuning의 차이 (0) | 2022.04.10 |
[딥러닝 필기] week6. CNN Basics: Convolution (0) | 2022.03.27 |
[딥러닝 필기] week6. Deep Learning-Various Technique: Batch Normalization (0) | 2022.03.27 |
[딥러닝 필기] week6. Deep Learning-Various Technique: Dropout (0) | 2022.03.27 |