mindformers.AutoConfig¶
- class mindformers.AutoConfig[源代码]¶
AutoConfig class, helps instantiates a config by yaml model name or path. If using a model name, the config yaml will be downloaded from obs to ./checkpoint_download dir
- Examples:
>>> from mindformers.auto_class import AutoConfig >>> >>> # 1) instantiates a config by yaml model name >>> config_a = AutoConfig.from_pretrained('clip_vit_b_32') >>> # 2) instantiates a config by yaml model path >>> from mindformers.mindformer_book import MindFormerBook >>> config_path = os.path.join(MindFormerBook.get_project_path(), ... 'configs', 'clip', 'run_clip_vit_b_32_pretrain_flickr8k.yaml') >>> config_b = AutoConfig.from_pretrained(config_path)
- classmethod from_pretrained(yaml_name_or_path, **kwargs)[源代码]¶
From pretrain method, which instantiates a config by yaml model name or path.
- Args:
- yaml_name_or_path (str): A supported model name or a path to model config (.yaml),
the supported model name could be selected from AutoConfig.show_support_list(). If yaml_name_or_path is model name, it supports model names beginning with mindspore or the model name itself, such as “mindspore/vit_base_p16” or “vit_base_p16”.
- pretrained_model_name_or_path (Optional[str]): Equal to “yaml_name_or_path”,
if “pretrained_model_name_or_path” is set, “yaml_name_or_path” is useless.
- Returns:
A model config, which inherited from BaseConfig.