2017-08-08 9 views
2

ケラスでmodel.summary()を理解しようとしています。私は以下の畳み込みニューラルネットワークを持っています。最初の畳み込みの値は次のとおりです。モデルを理解するsummary Keras

conv2d_4 (Conv2D)   (None, 148, 148, 16)  448 

ここで、148と448はどこから来たのですか?

コードKeras documentationから

image_input = layers.Input(shape=(150, 150, 3)) 
x = layers.Conv2D(16, 3, activation='relu')(image_input) 

x = layers.MaxPooling2D(2)(x) 
x = layers.Conv2D(32, 3, activation='relu')(x) 

x = layers.MaxPooling2D(2)(x) 
x = layers.Conv2D(64, 3, activation='relu')(x) 

x = layers.MaxPooling2D(2)(x) 
x = layers.Flatten()(x) 
x = layers.Dense(512, activation='relu')(x) 
output = layers.Dense(1, activation='sigmoid')(x) 

# Keras Model definition 
# input = input feature map 
# output = input feature map + stacked convolution/maxpooling layers + fully connected layer + sigmoid output layer 
model = Model(image_input, output) 
model.summary() 

出力

Layer (type)     Output Shape    Param # 
================================================================= 
input_2 (InputLayer)   (None, 150, 150, 3)  0   
_________________________________________________________________ 
conv2d_4 (Conv2D)   (None, 148, 148, 16)  448  
_________________________________________________________________ 
max_pooling2d_4 (MaxPooling2 (None, 74, 74, 16)  0   
_________________________________________________________________ 
conv2d_5 (Conv2D)   (None, 72, 72, 32)  4640  
_________________________________________________________________ 
max_pooling2d_5 (MaxPooling2 (None, 36, 36, 32)  0   
_________________________________________________________________ 
conv2d_6 (Conv2D)   (None, 34, 34, 64)  18496  
_________________________________________________________________ 
max_pooling2d_6 (MaxPooling2 (None, 17, 17, 64)  0   
_________________________________________________________________ 
flatten_1 (Flatten)   (None, 18496)    0   
_________________________________________________________________ 
dense_1 (Dense)    (None, 512)    9470464 
_________________________________________________________________ 
dense_2 (Dense)    (None, 1)     513  

答えて

1

、あなたはそのパディングがそうパディングがないことをdefault=validによっておよび進歩サイズが1であるということである見ることができます。出力形状は明らかに148 x 148です。

これは、この式を使用することができる計算する:

Oは、出力高さ/幅
O = (W - K + 2P)/S + 1 

を、Wは、入力高さ/幅であり、Kはフィルタのサイズであり、Pは、パディングであり、Sはストライドサイズであります。

機能マップは16で、カーネルサイズは3 x 3であるため、16 x(3 x 3)は144です。次に、3つのカラーチャネルがあり、144 x 3 = 432そして、あなたは448を作る16のバイアスを加える必要があります;)これが助けて欲しい!

関連する問題