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

Cropping3D 層

[原始碼]

Cropping3D 類別

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 = keras.layers.Cropping3D(cropping=(2, 4, 2))(x)
>>> 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) 的輸入。未指定時,使用在您的 Keras 設定檔 ~/.keras/keras.json (如果存在) 中找到的 image_data_format 值。預設為 "channels_last"

輸入形狀

5D 張量,形狀為: - 如果 data_format"channels_last": (batch_size, first_axis_to_crop, second_axis_to_crop, third_axis_to_crop, channels) - 如果 data_format"channels_first": (batch_size, channels, 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, channels) - 如果 data_format"channels_first": (batch_size, channels, first_cropped_axis, second_cropped_axis, third_cropped_axis)