代码拉取完成,页面将自动刷新
tf.image.per_image_standardization(
image
)
For more information, see tf.image.per_image_standardization.
class mindspore.dataset.vision.Normalize(
mean,
std,
is_hwc
)
For more information, see mindspore.dataset.vision.Normalize.
TensorFlow: Normalize the image using mean and standard deviation calculated automatically from the image.
MindSpore: Normalize the image using the specified mean and standard deviation.
# The following implements Normalize with MindSpore.
import numpy as np
import mindspore.dataset as ds
image = np.random.random((28, 28, 3))
mean = [np.mean(image, axis=(-1, -2, -3), keepdims=False)]
std = [np.std(image, axis=(-1, -2, -3), keepdims=False)]
adjusted_stddev = list(np.maximum(std, 1.0 / np.sqrt(image.size)))
result = ds.vision.Normalize(mean, adjusted_stddev)(image)
print(result.mean())
# 0.0
print(result.std())
# 1.0
# The following implements per_image_standardization with TensorFlow.
import tensorflow as tf
tf.compat.v1.enable_eager_execution()
image = tf.random.normal((28, 28, 3))
result = tf.image.per_image_standardization(image)
print(tf.math.reduce_mean(result))
# 0.0
print(tf.math.reduce_std(result))
# 1.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。