wkcn commented on a change in pull request #16175: [Dataset] add shard API URL: https://github.com/apache/incubator-mxnet/pull/16175#discussion_r324485736
########## File path: python/mxnet/gluon/data/dataset.py ########## @@ -64,6 +64,37 @@ def filter(self, fn): from . import FilterSampler return _SampledDataset(self, FilterSampler(fn, self)) + def shard(self, num_shards, index): + """Returns a new dataset includes only 1/num_shards of this dataset. + + For distributed training, be sure to shard before you randomize the dataset + (such as shuffle), if you want each worker to reach a unique subset. + + Parameters + ---------- + num_shards : int + A integer representing the number of data shards. + index : int + A integer representing the index of the current shard. + + Returns + ------- + Dataset + The result dataset. + """ Review comment: We also need the assertation `index >= 0` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services