zhreshold commented on a change in pull request #9514: Language Modeling 
Datasets and Sampler
URL: https://github.com/apache/incubator-mxnet/pull/9514#discussion_r163080913
 
 

 ##########
 File path: python/mxnet/gluon/data/sampler.py
 ##########
 @@ -136,3 +136,30 @@ def __len__(self):
         raise ValueError(
             "last_batch must be one of 'keep', 'discard', or 'rollover', " \
             "but got %s"%self._last_batch)
+
+
+class IntervalSampler(Sampler):
+    """Samples elements from [0, length) at fixed intervals.
+
+    Parameters
+    ----------
+    length : int
+        Length of the sequence.
+
+    Examples
+    --------
+    >>> sampler = gluon.data.IntervalSampler(13, interval=3)
+    >>> list(sampler)
+    [0, 3, 6, 9, 12, 1, 4, 7, 10, 2, 5, 8, 11]
+    """
+    def __init__(self, length, interval):
+        self._length = length
+        self._interval = interval
 
 Review comment:
   add range check?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Reply via email to