tensorflow下的图片标准化函数per_image_standardization
来源:互联网 发布:艾美仕待遇 知乎 编辑:程序博客网 时间:2024/06/07 03:38
实验环境:windows 7,anaconda 3(Python 3.5),tensorflow(gpu/cpu)
函数介绍:标准化处理可以使得不同的特征具有相同的尺度(Scale)。这样,在使用梯度下降法学习参数的时候,不同特征对参数的影响程度就一样了。tf.image.per_image_standardization(image),此函数的运算过程是将整幅图片标准化(不是归一化),加速神经网络的训练。主要有如下操作,(x - mean) / adjusted_stddev,其中x为图片的RGB三通道像素值,mean分别为三通道像素的均值,adjusted_stddev = max(stddev, 1.0/sqrt(image.NumElements()))。stddev为三通道像素的标准差,image.NumElements()计算的是三通道各自的像素个数。
实验代码:
import tensorflow as tfimport matplotlib.image as imgimport matplotlib.pyplot as pltimport numpy as npsess = tf.InteractiveSession()image = img.imread('D:/Documents/Pictures/logo7.jpg')shape = tf.shape(image).eval()h,w = shape[0],shape[1]standardization_image = tf.image.per_image_standardization(image)#标准化fig = plt.figure()fig1 = plt.figure()ax = fig.add_subplot(111)ax.set_title('orginal image')ax.imshow(image)ax1 = fig1.add_subplot(311)ax1.set_title('original hist')ax1.hist(sess.run(tf.reshape(image,[h*w,-1])))ax1 = fig1.add_subplot(313)ax1.set_title('standardization hist')ax1.hist(sess.run(tf.reshape(standardization_image,[h*w,-1])))plt.ion()plt.show()
实验结果:
两幅hist图分别是原图和标准化后的RGB的像素值分布图,可以看到只是将图片的像素值大小限定到一个范围,但是像素值的分布为改变。
阅读全文
0 0
- tensorflow下的图片标准化函数per_image_standardization
- 使用pillow实现tensorflow中的一些图像增强函数(crop,contrast,flip,per_image_standardization)
- tensorflow下有关图片的随机翻转、随机调整亮度以及对比度函数
- tensorflow下有关图片的随机翻转、随机调整亮度以及对比度函数
- tensorflow 批标准化Batch_normalization
- matlab zscore函数 数据的标准化处理
- tensorflow下的局部响应归一化函数tf.nn.lrn
- TensorFlow的reduce_sum()函数
- tensorflow的函数
- TensorFlow的variables_to_restore函数
- TensorFlow的convert_variables_to_constants函数
- TensorFlow的convert_variables_to_constants函数
- tensorflow读取图片的方法
- TensorFlow加载图片的方法
- matlab中用于数据的标准化处理的zscore函数
- 3.1 Tensorflow: 批标准化(Batch Normalization)
- tensorflow:批标准化(Bacth Normalization,BN)
- rancher下的kubernetes之一:构建标准化vmware镜像
- 从ADAS到自动驾驶(三):车道检测
- Django-数据库操作
- 14.3. Arithmetic and Relational Operators
- FileInputStream(字节流)与fileReader(字符流) 的区别
- 历届试题 幸运数
- tensorflow下的图片标准化函数per_image_standardization
- windows进程间通信方式
- springboot配置rediscluster
- Java_log2000_重载的定义
- Unity3D 动态批处理注意点
- 高斯混合模型——感性理解
- 对无验证码的问卷星问卷自动填充
- 使用you-get 下载视频
- mysql实现主从复制