Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save Numpy Array using Pickle

I've got a Numpy array that I would like to save (130,000 x 3) that I would like to save using Pickle, with the following code. However, I keep getting the error "EOFError: Ran out of input" or "UnsupportedOperation: read" at the pkl.load line. This is my first time using Pickle, any ideas?

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) 
like image 509
Anant Avatar asked Sep 21 '18 13:09

Anant


1 Answers

You should use numpy.save and numpy.load.

like image 137
piokuc Avatar answered Sep 22 '22 15:09

piokuc