From e0cb6712482f2e514103dcbd8491349b82866826 Mon Sep 17 00:00:00 2001 From: whs Date: Wed, 26 Jun 2019 11:15:33 +0800 Subject: [PATCH] Fix checkpoint of Light-NAS (#18332) Socket can't be pickled. test=release/1.5 --- .../paddle/fluid/contrib/slim/nas/light_nas_strategy.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python/paddle/fluid/contrib/slim/nas/light_nas_strategy.py b/python/paddle/fluid/contrib/slim/nas/light_nas_strategy.py index f5e9ca5ec..7f44510bd 100644 --- a/python/paddle/fluid/contrib/slim/nas/light_nas_strategy.py +++ b/python/paddle/fluid/contrib/slim/nas/light_nas_strategy.py @@ -127,6 +127,14 @@ class LightNASStrategy(Strategy): self._search_agent = SearchAgent( self._server_ip, self._server_port, key=self._key) + def __getstate__(self): + """Socket can't be pickled.""" + d = {} + for key in self.__dict__: + if key not in ["_search_agent", "_server"]: + d[key] = self.__dict__[key] + return d + def _constrain_func(self, tokens, context=None): """Check whether the tokens meet constraint.""" _, _, test_prog, _, _, _, _ = context.search_space.create_net(tokens) -- GitLab