roywei commented on a change in pull request #14685: [Fit API] improve event 
handlers
URL: https://github.com/apache/incubator-mxnet/pull/14685#discussion_r277094389
 
 

 ##########
 File path: python/mxnet/gluon/contrib/estimator/estimator.py
 ##########
 @@ -226,111 +230,72 @@ def fit(self, train_data,
             custom batch function to extract data and label
             from a data batch and load into contexts(devices)
         """
-
-        self.max_epoch = epochs
-        self.stop_training = False
-        self.processed_samples = None
-        self.batch_idx = 0
-
+        self.max_epochs = epochs
         event_handlers = event_handlers or []
         # provide default logging handler
-        if not event_handlers or \
-                not any(isinstance(handler, LoggingHandler) for handler in 
event_handlers):
-            event_handlers.append(LoggingHandler())
-            warnings.warn("No Event Handler specified, default 
`LoggingHandler()` "
-                          "is used with 
verbose=LoggingHandler.LOG_VERBOSITY_PER_EPOCH. "
-                          "Please look at gluon.estimator.event_handler for 
more detail.")
+        if not event_handlers:
+            train_metrics, val_metrics = self.prepare_loss_and_metrics()
+            event_handlers.append(MetricHandler(train_metrics=train_metrics))
+            if val_data:
+                event_handlers.append(ValidationHandler(val_data=val_data, 
eval_fn=self.evaluate,
+                                                        
val_metrics=val_metrics))
+            event_handlers.append(LoggingHandler(train_metrics=train_metrics,
+                                                 val_metrics=val_metrics))
+            warnings.warn("No Event Handler specified, default %s are used. "
 
 Review comment:
   Good point! for now we can only do this for estimator and handlers, any 
other warning from mxnet and gluon still  can't be controlled. tracked here: 
https://issues.apache.org/jira/browse/MXNET-1395 

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