想知道为什么conv2d中的参数数量比我期望的多1个...
import tensorflow as tf
import tensorflow.keras as keras
input_shape = (40, 512, 512, 1)
conv2d = keras.layers.Conv2D(input_shape=input_shape[1:],
filters=1,
kernel_size=3,
strides=(1, 1),
padding='same')
model = keras.Sequential(conv2d)
model.compile()
model.summary()
Output:
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d (Conv2D) (None, 512, 512, 1) 10
=================================================================
Total params: 10
Trainable params: 10
Non-trainable params: 0
_________________________________________________________________
由于内核大小为3,因此我期望它的Param#为9,但其值为10。
默认情况下,use_bias=True
。每个滤波器都有一个偏差,因此在这种情况下,您需要为偏差再添加1个参数。这总共提供了10个参数。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句