Load weight to model. Parameters ---------- weight_path : str Path to trained weight. Raises ------ RuntimeError Raised when the model has not yet been contructed. Returns ------- None.
(self, weight_path)
| 136 | return configs |
| 137 | |
| 138 | def load_weight(self, weight_path): |
| 139 | ''' |
| 140 | Load weight to model. |
| 141 | |
| 142 | Parameters |
| 143 | ---------- |
| 144 | weight_path : str |
| 145 | Path to trained weight. |
| 146 | |
| 147 | Raises |
| 148 | ------ |
| 149 | RuntimeError |
| 150 | Raised when the model has not yet been contructed. |
| 151 | |
| 152 | Returns |
| 153 | ------- |
| 154 | None. |
| 155 | ''' |
| 156 | if self.model is None: |
| 157 | raise RuntimeError("model has not yet been constructed.") |
| 158 | self.model.load_state_dict(torch.load(weight_path, map_location=self.device), strict=False) |
| 159 | self.model.eval() |
| 160 | |
| 161 | def construct_model(self, config): |
| 162 | ''' |