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
的元組,不包括樣本軸),例如 input_shape=(128, 128, 128, 1)
用於具有單通道的 128x128x128 體積,在 data_format="channels_last"
中。
範例
>>> # 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
)。輸入形狀
形狀為 5+D 的張量:如果 data_format='channels_first',則為 batch_shape + (channels, conv_dim1, conv_dim2, conv_dim3)
,如果 data_format='channels_last',則為形狀為 5+D 的張量: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)
,如果 data_format='channels_last',則為形狀為 5+D 的張量:batch_shape + (new_conv_dim1, new_conv_dim2, new_conv_dim3, filters)
。由於填充,new_conv_dim1
、new_conv_dim2
和 new_conv_dim3
的值可能會發生變化。
返回
一個表示 activation(conv3d(inputs, kernel) + bias)
的 5+ 階張量。
引發
padding
為 "causal"。strides > 1
和 dilation_rate > 1
時。