我有一个 Numpy 数组,我想使用 Pickle 保存它 (130,000 x 3),代码如下。但是,我不断在 pkl.load 行收到错误“EOFError:输入不足”或“UnsupportedOperation:read”。这是我第一次使用 Pickle,有什么想法吗?
谢谢,
阿南特
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.save和 numpy.load .
关于python - 使用 Pickle 保存 Numpy 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52444921/