Cropping2D
类keras.layers.Cropping2D(cropping=((0, 0), (0, 0)), data_format=None, **kwargs)
用于二维输入(例如图像)的裁剪层。
它沿着空间维度(即高度和宽度)进行裁剪。
示例
>>> input_shape = (2, 28, 28, 3)
>>> x = np.arange(np.prod(input_shape)).reshape(input_shape)
>>> y = keras.layers.Cropping2D(cropping=((2, 2), (4, 4)))(x)
>>> y.shape
(2, 24, 20, 3)
参数
(symmetric_height_crop, symmetric_width_crop)
。((top_crop, bottom_crop), (left_crop, right_crop))
。"channels_last"
(默认)或 "channels_first"
。输入中维度的顺序。"channels_last"
对应于形状为 (batch_size, height, width, channels)
的输入,而 "channels_first"
对应于形状为 (batch_size, channels, height, width)
的输入。如果未指定,则使用 Keras 配置文件 ~/.keras/keras.json
(如果存在)中找到的 image_data_format
值。默认为 "channels_last"
。输入形状
4D 张量,形状如下:- 如果 data_format
为 "channels_last"
:(batch_size, height, width, channels)
- 如果 data_format
为 "channels_first"
:(batch_size, channels, height, width)
输出形状
4D 张量,形状如下:- 如果 data_format
为 "channels_last"
:(batch_size, cropped_height, cropped_width, channels)
- 如果 data_format
为 "channels_first"
:(batch_size, channels, cropped_height, cropped_width)