From 572810eecb65412b09e38438ba5190255048582b Mon Sep 17 00:00:00 2001 From: LiuChiachi Date: Thu, 17 Dec 2020 14:44:34 +0800 Subject: [PATCH] Update EarlyStopping sample code (#29723) * update EarlyStopping doc * update EarlyStopping doc, test=document_fix --- python/paddle/hapi/callbacks.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/paddle/hapi/callbacks.py b/python/paddle/hapi/callbacks.py index 8567a2fff7..5f2949f651 100644 --- a/python/paddle/hapi/callbacks.py +++ b/python/paddle/hapi/callbacks.py @@ -714,7 +714,7 @@ class EarlyStopping(Callback): from paddle.vision.models import LeNet from paddle.vision.datasets import MNIST from paddle.metric import Accuracy - from paddle.nn.layer.loss import CrossEntropyLoss + from paddle.nn import CrossEntropyLoss import paddle.vision.transforms as T device = paddle.set_device('cpu') @@ -772,7 +772,8 @@ class EarlyStopping(Callback): self.best_weights = None self.stopped_epoch = 0 self.save_best_model = save_best_model - self.save_dir = None # `save_dir` is get from `config_callbacks` + # The value of `save_dir` is set in function `config_callbacks` + self.save_dir = None if mode not in ['auto', 'min', 'max']: warnings.warn('EarlyStopping mode %s is unknown, ' 'fallback to auto mode.' % mode) -- GitLab