From 79f7ba69877b038fa2607a28edea72ca53e2c253 Mon Sep 17 00:00:00 2001 From: WeiXin Date: Tue, 27 Apr 2021 16:32:22 +0800 Subject: [PATCH] edit paddle.save/load API (#32532) * edit paddle.save/load API * Update io.py edit doc * delete cpython-37.pyc * Update io.py edit doc * Update io.py recommit * Update io.py recommit * Update io.py recommit * Update io.py recommit --- python/paddle/framework/io.py | 8 ++++---- .../static_mode_white_list.cpython-37.pyc | Bin 20443 -> 0 bytes 2 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 tools/__pycache__/static_mode_white_list.cpython-37.pyc diff --git a/python/paddle/framework/io.py b/python/paddle/framework/io.py index 955d8610a59..ac0e172d49d 100644 --- a/python/paddle/framework/io.py +++ b/python/paddle/framework/io.py @@ -494,7 +494,7 @@ def save(obj, path, protocol=2, **configs): Save an object to the specified path. .. note:: - Now supports saving ``state_dict`` of Layer or Optimizer, Tensor. + Now supports saving ``state_dict`` of Layer/Optimizer, Layer, Tensor and nested structure containing Tensor. .. note:: Different from ``paddle.jit.save``, since the save result of ``paddle.save`` is a single file, @@ -558,7 +558,7 @@ def save(obj, path, protocol=2, **configs): prog = paddle.static.default_main_program() for var in prog.list_vars(): if list(var.shape) == [224, 10]: - tensor = var.get_tensor() + tensor = var.get_value() break # save/load tensor @@ -665,7 +665,7 @@ def load(path, **configs): Load an object can be used in paddle from specified path. .. note:: - Now supports load ``state_dict`` of Layer or Optimizer, Tensor. + Now supports loading ``state_dict`` of Layer/Optimizer, Layer, Tensor and nested structure containing Tensor. .. note:: In order to use the model parameters saved by paddle more efficiently, @@ -758,7 +758,7 @@ def load(path, **configs): prog = paddle.static.default_main_program() for var in prog.list_vars(): if list(var.shape) == [224, 10]: - tensor = var.get_tensor() + tensor = var.get_value() break # save/load tensor diff --git a/tools/__pycache__/static_mode_white_list.cpython-37.pyc b/tools/__pycache__/static_mode_white_list.cpython-37.pyc deleted file mode 100644 index b1e58ce7689c7db6cc0ce4ed18f87752b16d8beb..0000000000000000000000000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