Keras 2 API 文件 / 層 API / 形狀調整層 / Cropping3D 層

Cropping3D 層

[原始碼]

Cropping3D 類別

tf_keras.layers.Cropping3D(
    cropping=((1, 1), (1, 1), (1, 1)), data_format=None, **kwargs
)

用於 3D 資料(例如空間或時空資料)的裁剪層。

# 範例

>>> input_shape = (2, 28, 28, 10, 3)
>>> x = np.arange(np.prod(input_shape)).reshape(input_shape)
>>> y = tf.keras.layers.Cropping3D(cropping=(2, 4, 2))(x)
>>> print(y.shape)
(2, 24, 20, 6, 3)

參數

  • cropping:整數、或 3 個整數的元組、或 3 個各有 2 個整數的元組。
    • 如果為整數:則相同的對稱裁剪會應用於深度、高度和寬度。
    • 如果為 3 個整數的元組:則解釋為深度、高度和寬度的兩個不同對稱裁剪值:(symmetric_dim1_crop, symmetric_dim2_crop, symmetric_dim3_crop)
    • 如果為 3 個各有 2 個整數的元組:則解釋為 ((left_dim1_crop, right_dim1_crop), (left_dim2_crop, right_dim2_crop), (left_dim3_crop, right_dim3_crop))
  • data_format:字串,為 channels_last(預設)或 channels_first 其中之一。輸入中維度的排序。channels_last 對應的輸入形狀為 (batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels),而 channels_first 對應的輸入形狀為 (batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)。如果未指定,則會使用在您的 TF-Keras 設定檔 ~/.keras/keras.json(如果存在)中找到的 image_data_format 值,否則預設為 'channels_last'。預設為 'channels_last'。

輸入形狀

形狀為 5D 張量:- 如果 data_format"channels_last"(batch_size, first_axis_to_crop, second_axis_to_crop, third_axis_to_crop, depth) - 如果 data_format"channels_first"(batch_size, depth, first_axis_to_crop, second_axis_to_crop, third_axis_to_crop)

輸出形狀

形狀為 5D 張量:- 如果 data_format"channels_last"(batch_size, first_cropped_axis, second_cropped_axis, third_cropped_axis, depth) - 如果 data_format"channels_first"(batch_size, depth, first_cropped_axis, second_cropped_axis, third_cropped_axis)