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: int、3个int的元组或2个int的3个元组。
    • 如果是int:对深度、高度和宽度应用相同的对称裁剪。
    • 如果是3个int的元组:解释为深度、高度和宽度的两个不同的对称裁剪值:(symmetric_dim1_crop, symmetric_dim2_crop, symmetric_dim3_crop)
    • 如果是2个int的3个元组:解释为((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)