(self, state: dict)
Pickle import.
Pickle import.
Pickle import .
def __setstate__(self, state: dict) -> None:
        """Pickle import."""
        # pylint: disable=attribute-defined-outside-init
        tfutil.assert_tf_initialized()
        self._init_fields()

        # Execute custom import handlers.
        for handler in _import_handlers:
            state = handler(state)

        # Set basic fields.
        assert state["version"] in [2, 3, 4]
        self.name = state["name"]
        self.static_kwargs = util.EasyDict(state["static_kwargs"])
        self.components = util.EasyDict(state.get("components", {}))
        self._build_module_src = state["build_module_src"]
        self._build_func_name = state["build_func_name"]

        # Create temporary module from the imported source code.
        module_name = "_tflib_network_import_" + uuid.uuid4().hex
        module = types.ModuleType(module_name)
        sys.modules[module_name] = module
        _import_module_src[module] = self._build_module_src
        exec(self._build_module_src, module.__dict__) # pylint: disable=exec-used

        # Locate network build function in the temporary module.
        self._build_func = util.get_obj_from_module(module, self._build_func_name)
        assert callable(self._build_func)

        # Init TensorFlow graph.
        self._init_graph()
        self.reset_own_vars()
        tfutil.set_vars({self.find_var(name): value for name, value in state["variables"]})
def __setstate__ ( self , state : dict ) -> None : # pylint: disable=attribute-defined-outside-init tfutil . assert_tf_initialized ( ) self . _init_fields ( ) # Execute custom import handlers. for handler in _import_handlers : state = handler ( state ) # Set basic fields. assert state [ "version" ] in [ 2 , 3 , 4 ] self . name = state [ "name" ] self . static_kwargs = util . EasyDict ( state [ "static_kwargs" ] ) self . components = util . EasyDict ( state . get ( "components" , { } ) ) self . _build_module_src = state [ "build_module_src" ] self . _build_func_name = state [ "build_func_name" ] # Create temporary module from the imported source code. module_name = "_tflib_network_import_" + uuid . uuid4 ( ) . hex module = types . ModuleType ( module_name ) sys . modules [ module_name ] = module _import_module_src [ module ] = self . _build_module_src exec ( self . _build_module_src , module . __dict__ ) # pylint: disable=exec-used # Locate network build function in the temporary module. self . _build_func = util . get_obj_from_module ( module , self . _build_func_name ) assert callable ( self . _build_func ) # Init TensorFlow graph. self . _init_graph ( ) self . reset_own_vars ( ) tfutil . set_vars ( { self . find_var ( name ) : value for name , value in state [ "variables" ] } )