线性缩放 image 中的每个图像,使其具有均值 0 和方差 1。
用法
tf.image.per_image_standardization(
image
)参数
-
imagen-DTensor至少有 3 个维度,其中最后 3 个是每个图像的维度。
返回
-
与
image具有相同形状的Tensor,其 dtype 为float32。
抛出
-
ValueErrorimage的形状少于 3 个维度。
对于 image 中的每个 3-D 图像 x ,计算 (x - mean) / adjusted_stddev ,其中
mean是x中所有值的平均值adjusted_stddev = max(stddev, 1.0/sqrt(N))在处理统一图像时,上限为 0 以防止除以 0N是x中的元素个数stddev是x中所有值的标准差
示例用法:
image = tf.constant(np.arange(1, 13, dtype=np.int32), shape=[2, 2, 3])
image # 3-D tensor
<tf.Tensor:shape=(2, 2, 3), dtype=int32, numpy=
array([[[ 1, 2, 3],
[ 4, 5, 6]],
[[ 7, 8, 9],
[10, 11, 12]]], dtype=int32)>
new_image = tf.image.per_image_standardization(image)
new_image # 3-D tensor with mean ~= 0 and variance ~= 1
<tf.Tensor:shape=(2, 2, 3), dtype=float32, numpy=
array([[[-1.593255 , -1.3035723 , -1.0138896 ],
[-0.7242068 , -0.4345241 , -0.14484136]],
[[ 0.14484136, 0.4345241 , 0.7242068 ],
[ 1.0138896 , 1.3035723 , 1.593255 ]]], dtype=float32)>
相关用法
- Python tf.image.pad_to_bounding_box用法及代码示例
- Python tf.image.psnr用法及代码示例
- Python tf.image.random_brightness用法及代码示例
- Python tf.image.adjust_hue用法及代码示例
- Python tf.image.random_contrast用法及代码示例
- Python tf.image.rot90用法及代码示例
- Python tf.image.random_hue用法及代码示例
- Python tf.image.flip_left_right用法及代码示例
- Python tf.image.convert_image_dtype用法及代码示例
- Python tf.image.stateless_random_flip_up_down用法及代码示例
- Python tf.image.random_saturation用法及代码示例
- Python tf.image.extract_glimpse用法及代码示例
- Python tf.image.flip_up_down用法及代码示例
- Python tf.image.crop_to_bounding_box用法及代码示例
- Python tf.image.stateless_random_jpeg_quality用法及代码示例
- Python tf.image.crop_and_resize用法及代码示例
- Python tf.image.stateless_random_hue用法及代码示例
- Python tf.image.rgb_to_yiq用法及代码示例
- Python tf.image.stateless_random_crop用法及代码示例
- Python tf.image.resize_with_crop_or_pad用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.image.per_image_standardization。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
