karan6181 commented on a change in pull request #14587: [MXNET-1344, 1346][FIT
API] Retrieve Batch size and Logging verbose support for Gluon fit() API
URL: https://github.com/apache/incubator-mxnet/pull/14587#discussion_r271957858
##########
File path: python/mxnet/gluon/estimator/estimator.py
##########
@@ -175,14 +173,45 @@ def _batch_fn(self, batch, ctx, is_iterator=False):
label = gluon.utils.split_and_load(label, ctx_list=ctx, batch_axis=0)
return data, label
+ def infer_data_info(self, data):
+ """Retrieve the data information such as batch size,
+ Number of batches, and total number of samples
+
+ Parameters
+ ----------
+ data : DataLoader
+ A DataLoader instance with data and/or label
+
+ Returns
+ -------
+ num_batches: int
+ Number of batches the data is divided into
+ total_samples: int
+ Total Number of samples
+ batch_size: int
+ Batch size
+ """
+ if isinstance(data, gluon.data.DataLoader):
+ num_batches = len(data)
+ total_samples = len(data._dataset)
Review comment:
If the DataLoader created using `MXNet.gluon.data.dataset.ArrayDataset` then
the `ArrayDataset` has the instance variable `_length` which infers the length
of an actual data. Another way to infer the total number of sample is to
extract the `shape` information from the data.
----------------------------------------------------------------
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