Browse Source

update example of getnext and getnextsingleop

tags/v1.1.0
wangshuide2020 5 years ago
parent
commit
478dd7bc10
2 changed files with 24 additions and 12 deletions
  1. +12
    -9
      mindspore/nn/wrap/cell_wrapper.py
  2. +12
    -3
      mindspore/ops/operations/nn_ops.py

+ 12
- 9
mindspore/nn/wrap/cell_wrapper.py View File

@@ -263,17 +263,20 @@ class GetNextSingleOp(Cell):
For detailed information, refer to `ops.operations.GetNext`.

Supported Platforms:
``GPU``
``Ascend`` ``GPU``

Examples:
>>> # Refer to dataset_helper.py for detail usage.
>>> data_set = get_dataset()
>>> dataset_shapes = data_set.output_shapes()
>>> np_types = data_set.output_types()
>>> dataset_types = convert_type(dataset_shapes, np_types)
>>> queue_name = data_set.__TRANSFER_DATASET__.queue_name
>>> getnext_op = GetNextSingleOp(dataset_types, dataset_shapes, queue_name)
>>> getnext_op()
>>> train_dataset = create_custom_dataset()
>>> 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 = P.ReLU()
>>> result = relu(data).asnumpy()
>>> print(result.shape)
>>> (32, 1, 32, 32)
"""

def __init__(self, dataset_types, dataset_shapes, queue_name):


+ 12
- 3
mindspore/ops/operations/nn_ops.py View File

@@ -3017,14 +3017,23 @@ class GetNext(PrimitiveWithInfer):

Outputs:
tuple[Tensor], the output of Dataset. The shape is described in `shapes`
and the type is described is `types`.
and the type is described in `types`.

Supported Platforms:
``Ascend`` ``GPU``

Examples:
>>> get_next = ops.GetNext([mindspore.float32, mindspore.int32], [[32, 1, 28, 28], [10]], 2, 'shared_name')
>>> feature, label = get_next()
>>> train_dataset = create_custom_dataset()
>>> 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 = P.GetNext(dataset_types, dataset_shapes, len(dataset_types), queue_name)
>>> data, label = get_next()
>>> relu = P.ReLU()
>>> result = relu(data).asnumpy()
>>> print(result.shape)
>>> (32, 1, 32, 32)
"""

@prim_attr_register


Loading…
Cancel
Save