Cropping2D
類別keras.layers.Cropping2D(cropping=((0, 0), (0, 0)), data_format=None, **kwargs)
用於 2D 輸入(例如圖片)的裁剪層。
它沿空間維度裁剪,即高度和寬度。
範例
>>> 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)