Instantiate a pytorch model and return. By default, we will create a model using config from configuration file. You can override this method in a subclass.
(self)
| 809 | return self._metric_values |
| 810 | |
| 811 | def build_model(self) -> Union[nn.Module, TorchModel]: |
| 812 | """ Instantiate a pytorch model and return. |
| 813 | |
| 814 | By default, we will create a model using config from configuration file. You can |
| 815 | override this method in a subclass. |
| 816 | |
| 817 | """ |
| 818 | model = Model.from_pretrained( |
| 819 | self.model_dir, |
| 820 | cfg_dict=self.cfg, |
| 821 | trust_remote_code=self.trust_remote_code) |
| 822 | if not isinstance(model, nn.Module) and hasattr(model, 'model'): |
| 823 | return model.model |
| 824 | elif isinstance(model, nn.Module): |
| 825 | return model |
| 826 | |
| 827 | def to_parallel(self, model) -> Union[nn.Module, TorchModel]: |
| 828 | # config format to reserve custom ddp |
no test coverage detected