简体   繁体   中英

How to save numpy array of images dataset?

I am using my own dataset to train CNN. I have converted the images to a numpy array and the labels to another array. How can I save them to be able to load the data when I need to train the model? I tried pickle, but the data size is too big for it.

I am using python3.7 and tensorflow 2.1.1 .

There are many options to do so, one is to save it as csv file.

import numpy as np
np.savetxt("foo.csv", a, delimiter=",")

For a more efficient way, you can use HDF5 with h5py.

import h5py
h5f = h5py.File('data.h5', 'w')
h5f.create_dataset('dataset_1', data=a)

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