RandomShear 类keras.layers.RandomShear(
x_factor=0.0,
y_factor=0.0,
interpolation="bilinear",
fill_mode="reflect",
fill_value=0.0,
data_format=None,
seed=None,
**kwargs
)
一个对图像随机应用剪切变换的预处理层。
此层沿着 x 轴和/或 y 轴,以指定范围内的随机选取的因子对输入图像进行剪切。剪切变换独立应用于批次中的每个图像。变换过程中产生的空白区域将根据 fill_mode 和 fill_value 参数进行填充。
注意:该层可以在 tf.data 或 grain 管道中使用(无论您使用的是哪个后端),且是安全的。
参数
(0, x_factor)。值表示图像的剪切百分比。例如,0.3 表示将像素剪切到图像宽度的 30%。所有提供的值都应为正数。(0, y_factor)。值表示图像的剪切百分比。例如,0.3 表示将像素剪切到图像宽度的 30%。所有提供的值都应为正数。"nearest"、"bilinear"。"constant"、"nearest"、"wrap"和"reflect"。默认为"constant"。"reflect": `(d c b a | a b c d | d c b a)` 输入通过围绕最后一个像素的边缘进行反射来扩展。"constant":(k k k k | a b c d | k k k k) 输入通过使用 fill_value 指定的相同常量值 k 填充边缘之外的所有值来扩展。"wrap": `(a b c d | a b c d | a b c d)` 输入通过环绕到相对边缘进行扩展。"nearest":(a a a a | a b c d | d d d d) 输入通过最近的像素进行扩展。请注意,在使用 torch 后端时,"reflect" 将重定向到 "mirror" (c d c b | a b c d | c b a b),因为 torch 不支持 "reflect"。请注意,torch 后端不支持 "wrap"。fill_mode="constant" 时,表示边界外部填充的值的浮点数。