mindspore.connect_network_with_dataset

View Source On AtomGit
mindspore.connect_network_with_dataset(network, dataset_helper)[source]

Connect the network with the dataset in dataset_helper. Only supported in sink mode (dataset_sink_mode=True).

Parameters:
  • network (Cell) – The training network for dataset.

  • dataset_helper (DatasetHelper) – A class to process the MindData dataset. It provides the type, shape and queue name of the dataset.

Returns:

Cell, a new network containing the type, shape and queue name of the dataset info.

Raises:

RuntimeError – If the API was not called in dataset sink mode.

Supported Platforms:

Ascend GPU

Examples

>>> import numpy as np
>>> import mindspore as ms
>>> from mindspore import nn
>>> from mindspore import dataset as ds
>>>
>>> data = {"x": np.float32(np.random.rand(64, 10)), "y": np.random.randint(0, 5, (64,))}
>>> train_dataset = ds.NumpySlicesDataset(data=data).batch(32)
>>> dataset_helper = ms.DatasetHelper(train_dataset, dataset_sink_mode=True)
>>> net = nn.Dense(10, 5)
>>> net_with_dataset = ms.connect_network_with_dataset(net, dataset_helper)