Conv3D
类tf_keras.layers.Conv3D(
filters,
kernel_size,
strides=(1, 1, 1),
padding="valid",
data_format=None,
dilation_rate=(1, 1, 1),
groups=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
)
3D 卷积层(例如,体积上的空间卷积)。
此层创建一个卷积核,该卷积核与层输入进行卷积以产生输出张量。如果 use_bias
为 True,则创建一个偏差向量并将其添加到输出中。最后,如果 activation
不为 None
,则将其应用于输出。
在模型中将此层用作第一层时,请提供关键字参数 input_shape
(整数元组或 None
,不包括样本轴),例如,在 data_format="channels_last"
中,对于具有单个通道的 128x128x128 体积,input_shape=(128, 128, 128, 1)
。
示例
>>> # The inputs are 28x28x28 volumes with a single channel, and the
>>> # batch size is 4
>>> input_shape =(4, 28, 28, 28, 1)
>>> x = tf.random.normal(input_shape)
>>> y = tf.keras.layers.Conv3D(
... 2, 3, activation='relu', input_shape=input_shape[1:])(x)
>>> print(y.shape)
(4, 26, 26, 26, 2)
>>> # With extended batch shape [4, 7], e.g. a batch of 4 videos of
>>> # 3D frames, with 7 frames per video.
>>> input_shape = (4, 7, 28, 28, 28, 1)
>>> x = tf.random.normal(input_shape)
>>> y = tf.keras.layers.Conv3D(
... 2, 3, activation='relu', input_shape=input_shape[2:])(x)
>>> print(y.shape)
(4, 7, 26, 26, 26, 2)
参数
dilation_rate
值 != 1 不兼容。"valid"
或 "same"
之一(不区分大小写)。"valid"
表示不填充。"same"
会导致在输入的左侧/右侧或上下方用零均匀填充,以便输出具有与输入相同的宽度/高度维度。channels_last
(默认值)或 channels_first
之一。输入中维度的顺序。channels_last
对应于形状为 batch_shape + (spatial_dim1, spatial_dim2, spatial_dim3, channels)
的输入,而 channels_first
对应于形状为 batch_shape + (channels, spatial_dim1, spatial_dim2, spatial_dim3)
的输入。如果未指定,则使用 TF-Keras 配置文件(如果存在)中 ~/.keras/keras.json
中找到的 image_data_format
值,否则为 'channels_last'。请注意,TensorFlow 在 CPU 上目前不支持 channels_first
格式。默认为 'channels_last'。dilation_rate
值 != 1 与指定任何步长值 != 1 不兼容。filters / groups
个滤波器进行卷积。输出是所有 groups
结果沿通道轴的连接。输入通道和 filters
都必须可被 groups
整除。keras.activations
)。kernel
权重矩阵的初始化器(请参阅 keras.initializers
)。默认为 'glorot_uniform'。keras.initializers
)。默认为 'zeros'。kernel
权重矩阵的正则化函数(请参阅 keras.regularizers
)。keras.regularizers
)。keras.regularizers
)。keras.constraints
)。keras.constraints
)。输入形状
如果 data_format='channels_first',则为形状为 batch_shape + (channels, conv_dim1, conv_dim2, conv_dim3)
的 5+D 张量;如果 data_format='channels_last',则为形状为 batch_shape + (conv_dim1, conv_dim2, conv_dim3, channels)
的 5+D 张量。
输出形状
如果 data_format='channels_first',则为形状为 batch_shape + (filters, new_conv_dim1, new_conv_dim2, new_conv_dim3)
的 5+D 张量;如果 data_format='channels_last',则为形状为 batch_shape + (new_conv_dim1, new_conv_dim2, new_conv_dim3, filters)
的 5+D 张量。由于填充,new_conv_dim1
、new_conv_dim2
和 new_conv_dim3
值可能已更改。
返回值
一个秩为 5+ 的张量,表示 activation(conv3d(inputs, kernel) + bias)
。
引发异常
padding
为“causal”。strides > 1
和 dilation_rate > 1
时。