zburning commented on a change in pull request #16955: [Dataset] add flatten 
API to dataset
URL: https://github.com/apache/incubator-mxnet/pull/16955#discussion_r352959602
 
 

 ##########
 File path: python/mxnet/gluon/data/dataset.py
 ##########
 @@ -185,6 +185,20 @@ def transform_first(self, fn, lazy=True):
         """
         return self.transform(_TransformFirstClosure(fn), lazy)
 
+    def flatten(self):
+        """Returns a new dataset with samples flattened.
+
+        It is usefull to call after transform() when your transformer function 
'fn' transform
+        each sample into multiple samples.
+        Note that the items in dataset must be iterable, e.g., list.
+
+        Returns
+        -------
+        Dataset
+            The flattened dataset.
+        """
+        return SimpleDataset(list(itertools.chain.from_iterable(self)))
 
 Review comment:
   I guess you mean having a new class for example, flattenedDataset which 
implements __getitem__ and __len__ ?

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to