(self, model_dict, data=None, load_states=True)
Loads per layer (weights, states) and other model parameters from the
        dictionary passed.

        Arguments:
            model_dict (dict): dictionary describing the model including layers,
                               cost, optimizers, backend settings, etc.
                               generated by the serialize function
            data (NervanaDataIterator):   Data set (ignored, will be removed)
            load_states (bool):  if False, then only the weights will be loaded
                                 into a model in which the layers have already been
                                 created, otherwise will (re)create the layers from
                                 the serialized parameters and set the learning
                                 states as well
Loads per layer (weights, states) and other model parameters from the
        dictionary passed.
Loads per layer ( weights states ) and other model parameters from the dictionary passed .
def deserialize(self, model_dict, data=None, load_states=True):
        """
        Loads per layer (weights, states) and other model parameters from the
        dictionary passed.

        Arguments:
            model_dict (dict): dictionary describing the model including layers,
                               cost, optimizers, backend settings, etc.
                               generated by the serialize function
            data (NervanaDataIterator):   Data set (ignored, will be removed)
            load_states (bool):  if False, then only the weights will be loaded
                                 into a model in which the layers have already been
                                 created, otherwise will (re)create the layers from
                                 the serialized parameters and set the learning
                                 states as well
        """

        if data is not None:
            logger.warning('data is a deprecated argument and will be ignored')

        if 'epoch_index' in model_dict:
            self.epoch_index = model_dict['epoch_index']
        if 'model' not in model_dict:
            logger.error('Using old model serialization format. '
                         'Serialized the model into new format')

            param_layers = [l for l in self.layers_to_optimize]
            param_dict_list = model_dict['layer_params_states']
            for l, ps in zip(param_layers, param_dict_list):
                l.set_params(ps)
                if 'states' in ps and load_states:
                    l.set_states(ps)
            return

        if 'backend' in model_dict:
            if 'compat_mode' in model_dict['backend']:
                self.be.compat_mode = model_dict['backend']['compat_mode']
        else:
            model_dict['backend'] = {}

        typ = model_dict['model']['type']
        main_container = load_class(typ)

        if not hasattr(self, 'layers'):
            self.layers = main_container.gen_class(model_dict['model']['config'])

        self.layers.load_weights(model_dict['model'], load_states)

        if load_states and 'rng_state' in model_dict['backend']:
            try:
                self.be.rng_set_state(model_dict['backend']['rng_state'])
            except ValueError as e:
                # could come about when switching backend types (ex GPU to CPU)
                logger.warning("Problems restoring existing RNG state: %s", str(e))
def deserialize ( self , model_dict , data = None , load_states = True ) : if data is not None : logger . warning ( 'data is a deprecated argument and will be ignored' ) if 'epoch_index' in model_dict : self . epoch_index = model_dict [ 'epoch_index' ] if 'model' not in model_dict : logger . error ( 'Using old model serialization format. ' 'Serialized the model into new format' ) param_layers = [ l for l in self . layers_to_optimize ] param_dict_list = model_dict [ 'layer_params_states' ] for l , ps in zip ( param_layers , param_dict_list ) : l . set_params ( ps ) if 'states' in ps and load_states : l . set_states ( ps ) return if 'backend' in model_dict : if 'compat_mode' in model_dict [ 'backend' ] : self . be . compat_mode = model_dict [ 'backend' ] [ 'compat_mode' ] else : model_dict [ 'backend' ] = { } typ = model_dict [ 'model' ] [ 'type' ] main_container = load_class ( typ ) if not hasattr ( self , 'layers' ) : self . layers = main_container . gen_class ( model_dict [ 'model' ] [ 'config' ] ) self . layers . load_weights ( model_dict [ 'model' ] , load_states ) if load_states and 'rng_state' in model_dict [ 'backend' ] : try : self . be . rng_set_state ( model_dict [ 'backend' ] [ 'rng_state' ] ) except ValueError as e : # could come about when switching backend types (ex GPU to CPU) logger . warning ( "Problems restoring existing RNG state: %s" , str ( e ) )