简体   繁体   中英

How to save Numpy 4D array to CSV?

I am trying to save a series of images to CSV file so they can be used as a training dataset for Alexnet Keras machine learning. The shape is (15,224,224,3).

So far I am having issue doing this. I have managed to put all data into a numpy array but now I cannot save it to a file.

Please help.

I don't think saving it to a csv file is the correct way to do this, it's used for 1d or 2d data to create a table-like structure, so I'm going to offer another solution. You can use np.save to save any numpy array to a file;

np.save('file_name', your_array)

which can then be loaded using np.load ;

loaded_array = np.load('file_name.npy')

Hope that this works for you.

You can try using pickle to save the data. It is much more diverse and easy to handle compare to np.save.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM