paddlenlp/transformers/ernie_gen/modeling.py
def save_pretrained(self, save_directory):
        """
        Save model configuration and related resources (model state) to files
        under `save_directory`.
        Args:
            save_directory (str): Directory to save files into.
        """
        assert os.path.isdir(
            save_directory
        ), "Saving directory ({}) should be a directory".format(save_directory)
        # save model config
        model_config_file = os.path.join(save_directory, self.model_config_file)
        model_config = self.init_config
        # If init_config contains a Layer, use the layer's init_config to save
        for key, value in model_config.items():
            if key == "init_args":
                args = []
                for arg in value:
                    args.append(
                        arg.init_config
                        if isinstance(arg, ErnieGenPretrainedModel) else arg)
                model_config[key] = tuple(args)
            elif isinstance(value, ErnieGenPretrainedModel):
                model_config[key] = value.init_config
        with io.open(model_config_file, "w", encoding="utf-8") as f:
            f.write(json.dumps(model_config, ensure_ascii=False))
        # save model
        file_name = os.path.join(save_directory,
                                 list(self.resource_files_names.values())[0])
        paddle.save(self.state_dict(), file_name)

        Save model configuration and related resources (model state) to files
        under `save_directory`.
        Args:
            save_directory (str): Directory to save files into.
        
Save model configuration and related resources (model state) to files
under `save_directory`.
Save model configuration and related resources ( model state ) to files under ` save_directory ` .
def save_pretrained(self, save_directory):
        assert os.path.isdir(
            save_directory
        ), "Saving directory ({}) should be a directory".format(save_directory)
        model_config_file = os.path.join(save_directory, self.model_config_file)
        model_config = self.init_config
        for key, value in model_config.items():
            if key == "init_args":
                args = []
                for arg in value:
                    args.append(
                        arg.init_config
                        if isinstance(arg, ErnieGenPretrainedModel) else arg)
                model_config[key] = tuple(args)
            elif isinstance(value, ErnieGenPretrainedModel):
                model_config[key] = value.init_config
        with io.open(model_config_file, "w", encoding="utf-8") as f:
            f.write(json.dumps(model_config, ensure_ascii=False))
        file_name = os.path.join(save_directory,
                                 list(self.resource_files_names.values())[0])
        paddle.save(self.state_dict(), file_name)
def save_pretrained ( self , save_directory ) : assert os . path . isdir ( save_directory ) , "Saving directory ({}) should be a directory" . format ( save_directory ) model_config_file = os . path . join ( save_directory , self . model_config_file ) model_config = self . init_config for key , value in model_config . items ( ) : if key == "init_args" : args = [ ] for arg in value : args . append ( arg . init_config if isinstance ( arg , ErnieGenPretrainedModel ) else arg ) model_config [ key ] = tuple ( args ) elif isinstance ( value , ErnieGenPretrainedModel ) : model_config [ key ] = value . init_config with io . open ( model_config_file , "w" , encoding = "utf-8" ) as f : f . write ( json . dumps ( model_config , ensure_ascii = False ) ) file_name = os . path . join ( save_directory , list ( self . resource_files_names . values ( ) ) [ 0 ] ) paddle . save ( self . state_dict ( ) , file_name )
Save model configuration and related resources (model state) to files
under `save_directory`.
Save model configuration and related resources ( model state ) to files under ` save_directory ` .
"""
        Save model configuration and related resources (model state) to files
        under `save_directory`.
        Args:
            save_directory (str): Directory to save files into.
        """ # save model config # If init_config contains a Layer, use the layer's init_config to save # save model
self
save_directory
Directory to save files into.
Directory to save files into .