(cls, path)
| 220 | |
| 221 | @classmethod |
| 222 | def load(cls, path): |
| 223 | if th.cuda.is_available(): |
| 224 | device = 'cuda' |
| 225 | else: |
| 226 | device = 'cpu' |
| 227 | saved_variables = th.load(path, map_location=device) |
| 228 | # Create policy object |
| 229 | model = cls(**saved_variables['policy_init_kwargs']) |
| 230 | |
| 231 | # Load weights |
| 232 | model.load_state_dict(saved_variables['policy_state_dict']) |
| 233 | model.to(device) |
| 234 | return model, saved_variables['train_init_kwargs'] |
| 235 | |
| 236 | @staticmethod |
| 237 | def init_weights(module: nn.Module, gain: float = 1) -> None: |
no outgoing calls
no test coverage detected