我有一个 Numpy 数组,我想保存它(130,000 x 3),我想使用 Pickle 保存它,代码如下。但是,我在 pkl.load 行不断收到错误“EOFError:Ran out of input”或“UnsupportedOperation:read”。这是我第一次使用 Pickle,有什么想法吗?
Thanks,
Anant
import pickle as pkl
import numpy as np
arrayInput = np.zeros((1000,2)) #Trial input
save = True
load = True
filename = path + 'CNN_Input'
fileObject = open(fileName, 'wb')
if save:
pkl.dump(arrayInput, fileObject)
fileObject.close()
if load:
fileObject2 = open(fileName, 'wb')
modelInput = pkl.load(fileObject2)
fileObject2.close()
if arrayInput == modelInput:
Print(True)
你应该使用numpy.保存 https://docs.scipy.org/doc/numpy/reference/generated/numpy.save.html and numpy.load https://docs.scipy.org/doc/numpy/reference/generated/numpy.load.html#numpy.load.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)