From 73289709742b11f7267f5cc21e78aa796148288c Mon Sep 17 00:00:00 2001 From: michaelowenliu Date: Mon, 21 Sep 2020 11:13:14 +0800 Subject: [PATCH] using callbacks in core/train --- dygraph/paddleseg/cvlibs/callbacks.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/dygraph/paddleseg/cvlibs/callbacks.py b/dygraph/paddleseg/cvlibs/callbacks.py index 60e029e8..952c97d8 100644 --- a/dygraph/paddleseg/cvlibs/callbacks.py +++ b/dygraph/paddleseg/cvlibs/callbacks.py @@ -274,19 +274,4 @@ class VisualDL(Callback): self.writer.flush() def on_train_end(self, logs=None): - self.writer.close() - -if __name__ == "__main__": - - paddle.disable_static() - x = np.random.uniform(-1, 1, [10, 10]).astype("float32") - linear = paddle.nn.Linear(10, 10) - scheduler = paddle.optimizer.lr_scheduler.PolynomialLR(learning_rate=0.5, decay_steps=20) - sgd = paddle.optimizer.SGD(learning_rate=scheduler, parameters=linear.parameters()) - - callbacks1 = ModelCheckpoint(save_dir="/mnt/liuyi22/PaddlePaddle/PaddleSeg/dygraph/1", verbose=1, period=10) - callback_list = CallbackList([callbacks1]) - callback_list.set_model(linear) - - for iter in range(100): - callback_list.on_iter_end(iter) \ No newline at end of file + self.writer.close() \ No newline at end of file -- GitLab