了解 Keras Conv2D 层中的参数数量

Lak*_*hay 9 convolution conv-neural-network keras

我的第一层是:

model.add(tf.keras.layers.Conv2D(filters=32, kernel_size=3, padding="same", activation="relu", input_shape=[32, 32, 3]))
Run Code Online (Sandbox Code Playgroud)

以及Model汇总表中的参数个数:

    Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_4 (Conv2D)            (None, 32, 32, 32)        896  
Run Code Online (Sandbox Code Playgroud)

根据我的理解,参数的数量必须是:

(No of filters) X (Number of parameters in Kernel)
Run Code Online (Sandbox Code Playgroud)

即在我的情况下==> 32 X (3 X 3) = 288

但它的896。它是怎么来的896?

谢谢

Kau*_*Roy 12

Keras Conv2D 层中的参数数量使用以下等式计算:

number_parameters = out_channels * (in_channels * kernel_h * kernel_w + 1)  # 1 for bias
Run Code Online (Sandbox Code Playgroud)

所以,在你的情况下,

in_channels = 3
out_channels = 32
kernel_h = kernel_w = 3
number_parameters = 32(3*3*3 + 1) = 896
Run Code Online (Sandbox Code Playgroud)