详解keras的model.summary()输出参数Param计算过程 最难的是卷积层
1、代码产生conv_1层 他的 param 参数为:(通道数2*(核宽2*核高2)+1)*卷积核数3=27
2、代码产生conv_2层 他的 param 参数为:(上层卷积核数3*(核宽3*核高3)+1)*卷积核数24=672
image = Input(shape=(5,5,通道数2),name="input_my")
1、x = Conv2D(卷积核数3, kernel_size=(核宽2,核高2), strides=(1,1), activation='relu', name='conv_1')(image)
2、x = Conv2D(24, kernel_size=(核宽3,核高3), strides=(1,1), activation='relu', name='conv_2')(x)
from keras import *
from keras.layers import Conv2D,Flatten,Dense
import numpy as np
def create_model():
#------------------------------------
image = Input(shape=(5,5,2),name="input_my")
x = Conv2D(3, kernel_size=(2,2), strides=(1,1), activation='relu', name='conv_1')(image)
x = Conv2D(24, kernel_size=(3,3), strides=(1,1), activation='relu', name='conv_2')(x)
#-------------------------------------------
output = Dense(1, activation='relu', name='output')(x)
model = Model(inputs=image, outputs=output)
return model
Layer (type) Output Shape Param #
=================================================================
input_my (InputLayer) (None, 5, 5, 2) 0
_________________________________________________________________
conv_1 (Conv2D) (None, 4, 4, 3) 27
_________________________________________________________________
conv_2 (Conv2D) (None, 2, 2, 24) 672
_________________________________________________________________
output (Dense) (None, 2, 2, 1) 25
=================================================================