mindformers.models.BaseConfig¶
- class mindformers.models.BaseConfig(**kwargs)[源代码]¶
Base Config for all models’ config
- Examples:
>>> from mindformers.mindformer_book import MindFormerBook >>> from mindformers.models.base_config import BaseConfig >>> class MyConfig(BaseConfig): ... _support_list = MindFormerBook.get_config_support_list()['my_model'] ... ... def __init__(self, ... data_size: int = 32, ... net_size: list = [1, 2, 3], ... loss_type: str = "MyLoss", ... checkpoint_name_or_path: str = '', ... **kwargs): ... self.data_size = data_size ... self.net_size = net_size ... loss_type = loss_type ... self.checkpoint_name_or_path = checkpoint_name_or_path ... super(MyConfig, self).__init__(**kwargs) ... >>> mynet = MyModel(MyConfig) >>> output = mynet(input)
- classmethod from_pretrained(yaml_name_or_path, **kwargs)[源代码]¶
From pretrain method, which instantiates a config by yaml 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.