roywei 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_r272281252
##########
File path: python/mxnet/gluon/estimator/estimator.py
##########
@@ -175,14 +174,51 @@ 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):
+ if isinstance(data._dataset, gluon.data.ArrayDataset):
+ total_samples = data._dataset._data[0].shape[0]
+ elif isinstance(data._dataset, nd.ndarray.NDArray):
Review comment:
add some comments on why you are avoiding using `len(dataset)`
----------------------------------------------------------------
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