ArrayDataset¶
- class ArrayDataset(*arrays)[source]¶
ArrayDataset is a dataset for numpy array data.
One or more numpy arrays are needed to initiate the dataset. And the dimensions represented sample number are expected to be the same.
- Parameters
Arrays (dataset and labels) – the datas and labels to be returned iteratively.
- Returns
A set of raw data and corresponding label.
- Return type
Tuple
Examples
from megengine.data.dataset import ArrayDataset from megengine.data.dataloader import DataLoader from megengine.data.sampler import SequentialSampler rand_data = np.random.randint(0, 255, size=(sample_num, 1, 32, 32), dtype=np.uint8) label = np.random.randint(0, 10, size=(sample_num,), dtype=int) dataset = ArrayDataset(rand_data, label) seque_sampler = SequentialSampler(dataset, batch_size=2) dataloader = DataLoader( dataset, sampler = seque_sampler, num_workers=3, ) for step, data in enumerate(dataloader): print(data)