piiswrong closed pull request #10437: [MXNET-171] Fix a bug that was causing 
training accuracy to be printed as nan sometimes
URL: https://github.com/apache/incubator-mxnet/pull/10437
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/python/mxnet/module/base_module.py 
b/python/mxnet/module/base_module.py
index c03f8e73cda..8f5fd4ab854 100644
--- a/python/mxnet/module/base_module.py
+++ b/python/mxnet/module/base_module.py
@@ -522,6 +522,9 @@ def fit(self, train_data, eval_data=None, eval_metric='acc',
                 if monitor is not None:
                     monitor.toc_print()
 
+                if end_of_batch:
+                    eval_name_vals = eval_metric.get_name_value()
+
                 if batch_end_callback is not None:
                     batch_end_params = BatchEndParam(epoch=epoch, 
nbatch=nbatch,
                                                      eval_metric=eval_metric,
@@ -531,7 +534,7 @@ def fit(self, train_data, eval_data=None, eval_metric='acc',
                 nbatch += 1
 
             # one epoch of training is finished
-            for name, val in eval_metric.get_name_value():
+            for name, val in eval_name_vals:
                 self.logger.info('Epoch[%d] Train-%s=%f', epoch, name, val)
             toc = time.time()
             self.logger.info('Epoch[%d] Time cost=%.3f', epoch, (toc-tic))


 

----------------------------------------------------------------
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