1.pickle模块
def unpickle(file):
with open(file, 'rb') as fo:
dict = pickle.load(fo, encoding='bytes')
return dict
-
open函数:open(file, ‘rb’)
- file :必需,文件路径(相对或者绝对路径)
- ‘rb’ :以二进制格式打开一个文件用于只读。文件指针将会放在文件的开头。这是默认模式。一般用于非文本文件如图片等。
- open函数
-
pikle模块:模块 pickle 实现了对一个 Python 对象结构的二进制序列化和反序列化(用于python特有的类型和python的数据类型间进行转换)
- pickle.load(file,encoding=“ASCII”) : 默认encoding方式“ASCII”,这里要改成“bytes”
———————————————————————————————————————————————————————
2.(numpy数组操作)reshape,transpose,astype
n = len(images)
images = images.reshape(n,3,32,32).transpose(0,2,3,1).