mindspore.nn.GetNextSingleOp
- class mindspore.nn.GetNextSingleOp(dataset_types, dataset_shapes, queue_name)[源代码]
用于获取下一条数据的Cell。更详细的信息请参考
mindspore.ops.GetNext
。- 参数:
dataset_types (list[
mindspore.dtype
]) - 数据集类型。dataset_shapes (list[tuple[int]]) - 数据集的shape。
queue_name (str) - 待获取数据的队列名称。
- 输出:
tuple[Tensor],从数据集中获取的数据。
- 支持平台:
Ascend
GPU
样例:
>>> import mindspore >>> from mindspore import ops, nn >>> from mindspore import dataset as ds >>> from mindspore import dtype as mstype >>> >>> data_path = "/path/to/MNIST_Data/train/" >>> train_dataset = ds.MnistDataset(data_path, num_samples=10) >>> dataset_helper = mindspore.DatasetHelper(train_dataset, dataset_sink_mode=True) >>> dataset = dataset_helper.iter.dataset >>> dataset_types, dataset_shapes = dataset_helper.types_shapes() >>> queue_name = dataset.__transfer_dataset__.queue_name >>> get_next_single_op_net = nn.GetNextSingleOp(dataset_types, dataset_shapes, queue_name) >>> data, label = get_next_single_op_net() >>> relu = ops.ReLU() >>> result = relu(data.astype(mstype.float32)) >>> print(result.shape) (28, 28, 1)