From cc2edc5ed8aa1f731f68c6a724b218d78020c3d6 Mon Sep 17 00:00:00 2001 From: Jiaqi Liu Date: Fri, 18 Dec 2020 19:42:19 +0800 Subject: [PATCH] Update EarlyStopping sample code (#29723) (#29727) * 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 8567a2fff7d..5f2949f6513 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