图片处理
1 更改图片尺寸
1 | import os |
2 把图片转为3维数组(两种方法)
用np + Image
1 | import numpy as np |
用Tensorflow
1 | import tensorflow as tf |
3 整合1,2实现把图片转为指定大小的三维数组★
1 | import numpy as np |
数据处理
1 cifar-10 数据读取
1 | def load_CIFAR_batch(filename): |
2 标签数据 one-hot 编码
1、python方法
1 | def GetOneHotLabel(label, numClass): |
2、Tensorflow方法
1 | #例子 |
3 归一化
把图片像素压缩到[-1,1]之间
1 | image = tf.cast(image, tf.float32) * (1. / 255) - 0.5 |
4 标准化
1 | def per_image_standardization(image): |
ceshi444444