Save Numpy Array using Pickle

后端 未结 6 1952
独厮守ぢ
独厮守ぢ 2021-02-18 20:59

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: Ra

6条回答
  •  失恋的感觉
    2021-02-18 21:26

    In your code, you're using

    if load:
        fileObject2 = open(fileName, 'wb')
        modelInput = pkl.load(fileObject2)
        fileObject2.close()
    

    The second argument in the open function is the method. w stands for writing, r for reading. The second character b denotes that bytes will be read/written. A file that will be written to cannot be read and vice versa. Therefore, opening the file with fileObject2 = open(fileName, 'rb') will do the trick.

提交回复
热议问题