Resizing
类keras.layers.Resizing(
height,
width,
interpolation="bilinear",
crop_to_aspect_ratio=False,
pad_to_aspect_ratio=False,
fill_mode="constant",
fill_value=0.0,
antialias=False,
data_format=None,
**kwargs
)
用于调整图像大小的预处理层。
此层将输入图像调整为目标高度和宽度。输入应为 "channels_last"
格式的 4D(批处理)或 3D(非批处理)张量。输入像素值可以是任何范围(例如 [0., 1.)
或 [0, 255]
)。
输入形状
3D(非批处理)或 4D(批处理)张量,形状为:在 "channels_last"
格式下为 (..., height, width, channels)
,或在 "channels_first"
格式下为 (..., channels, height, width)
。
输出形状
3D(非批处理)或 4D(批处理)张量,形状为:(..., target_height, target_width, channels)
(在 "channels_last"
格式下),或 (..., channels, target_height, target_width)
(在 "channels_first"
格式下)。
注意:此层可在 tf.data
流水线中安全使用(无论您使用哪个后端)。
参数
"bilinear"
、"nearest"
、"bicubic"
、"lanczos3"
、"lanczos5"
。默认为 "bilinear"
。True
,则在不失真长宽比的情况下调整图像大小。当原始长宽比与目标长宽比不同时,输出图像将被裁剪,以便返回图像中与目标长宽比匹配的尽可能大的窗口(大小为 (height, width)
)。默认情况下(crop_to_aspect_ratio=False
),可能不保留长宽比。True
,则在不失真长宽比的情况下对图像进行填充。当原始长宽比与目标长宽比不同时,输出图像将在短边上进行均匀填充。pad_to_aspect_ratio=True
时,填充区域根据给定模式填充。目前仅支持 "constant"
(用常数值填充,等于 fill_value
)。pad_to_aspect_ratio=True
时使用的填充值。"channels_last"
或 "channels_first"
。输入中维度的顺序。"channels_last"
对应于形状为 (batch, height, width, channels)
的输入,而 "channels_first"
对应于形状为 (batch, channels, height, width)
的输入。它默认为 Keras 配置文件 ~/.keras/keras.json
中找到的 image_data_format
值。如果您从未设置它,则默认为 "channels_last"
。name
和 dtype
。