参考自tf2.1
官方文档:
https://www.tensorflow.org/api_docs/python/tf/keras/layers/Conv2D
(笔者时间紧迫,暂时只将常用的参数记录,某若有闲时再补)
2D convolution layer (e.g. spatial convolution over images).
该函数用于指明Keras中的2D卷积层.
tf.keras.layers.Conv2D( # 别被参数吓着,常用的就那么几个
filters,
kernel_size,
strides=(1, 1),
padding='valid',
data_format=None,
dilation_rate=(1, 1),
activation=None,
use_bias=True,
kernel_initializer='glorot_uniform',
bias_initializer='zeros',
kernel_regularizer=None,
bias_regularizer=None,
activity_regularizer=None,
kernel_constraint=None,
bias_constraint=None,
**kwargs
)
This layer creates a convolution kernel that is convolved with the layer input to produce a tensor of outputs.
该层创建一个卷积核,该卷积核与该层输入进行卷积以产生输出张量。
If use_bias
is True
, a bias vector is created and added to the outputs. Finally, if activation
is not None, it is applied to the outputs as well.
如果use_bias
为True
,则会创建一个偏差矢量并将其添加到输出中。最后,如果 activation
不是None
,那么它也将应用于输出。
When using this layer as the first layer in a model, provide the keyword argument input_shape
(tuple of integers, does not include the sample axis).
e.g. input_shape=(128, 128, 3)
for 128x128 RGB pictures in data_format="channels_last"
.
当将此层用作模型的第一层时,请提供关键字参数input_shape
(整数元组,不包括采样轴)
例如,若指定data_format="channels_last"
,则input_shape=(128, 128, 3)
用于中的128x128 RGB图片。
Arguments:
filters
: Integer, the dimensionality of the output space (i.e. the number of output filters in the convolution).-
f
i
l
t
e
r
s
filters
filters: 整型,输出空间的维数(即卷积中输出
filter
的数量)
kernel_size
: An integer or tuple/list of 2 integers, specifying the height and width of the 2D convolution window. Can be a single integer to specify the same value for all spatial dimensions.-
k
e
r
n
e
l
_
s
i
z
e
kernel\_size
kernel_size: 一个整数,或者2个元素的元组/列表,指定2D卷积窗口的高度和宽度。
当时单个整数时,给所有卷积核的宽高指定相同的值。
-
strides
: An integer or tuple/list of 2 integers, specifying the strides of the convolution along the height and width. Can be a single integer to specify the same value for all spatial dimensions. Specifying any stride value != 1 is incompatible with specifying any dilation_rate value != 1. -
s t r i d e s strides strides: 一个整数,或2个整数的元组/列表,指定沿高度和宽度方向卷积的步长。可以是单个整数,给两个方向的步长指定相同的值。
指定任何步长 != 1与指定任何dilation_rate
值 != 1 不兼容。
padding
: one of “valid” or “same” (case-insensitive).- p a d d i n g padding padding:可以选择 " v a l i d " "valid" "valid"或 " s a m e " "same" "same"(不区分大小写)。
data_format
: A string, one of channels_last (default) or channels_first. The ordering of the dimensions in the inputs. channels_last corresponds to inputs with shape (batch, height, width, channels) while channels_first corresponds to inputs with shape (batch, channels, height, width). It defaults to the image_data_format value found in your Keras config file at ~/.keras/keras.json. If you never set it, then it will be “channels_last”.
dilation_rate
: an integer or tuple/list of 2 integers, specifying the dilation rate to use for dilated convolution. Can be a single integer to specify the same value for all spatial dimensions. Currently, specifying any dilation_rate value != 1 is incompatible with specifying any stride value != 1.
activation
: Activation function to use. If you don’t specify anything, no activation is applied (ie. “linear” activation: a(x) = x).- a c t i v a t i o n activation activation:指定要使用的激活函数。如果参数不指定激活函数,则将不使用激活函数,即"线性激活函数": a ( x ) = x a(x) = x a(x)=x
use_bias
: Boolean, whether the layer uses a bias vector.- u s e _ b i a s use\_bias use_bias: 布尔值,指定该层是否使用偏置向量
kernel_initializer
: Initializer for the kernel weights matrix.bias_initializer
: Initializer for the bias vector.kernel_regularizer
: Regularizer function applied to the kernel weights matrix.bias_regularizer
: Regularizer function applied to the bias vector.activity_regularizer
: Regularizer function applied to the output of the layer (its “activation”)…-
kernel_constraint
: Constraint function applied to the kernel matrix. bias_constraint
: Constraint function applied to the bias vector.