Returns a dict containing the current state of this :class:`FP16_Optimizer` instance. This dict contains attributes of :class:`FP16_Optimizer`, as well as the state_dict of the contained Pytorch optimizer. Example:: checkpoint = {} checkpoi
(self)
| 290 | return -1 |
| 291 | |
| 292 | def state_dict(self): |
| 293 | """ |
| 294 | Returns a dict containing the current state of this :class:`FP16_Optimizer` |
| 295 | instance. This dict contains attributes of :class:`FP16_Optimizer`, as |
| 296 | well as the state_dict of the contained Pytorch optimizer. |
| 297 | Example:: |
| 298 | |
| 299 | checkpoint = {} |
| 300 | checkpoint['model'] = model.state_dict() |
| 301 | checkpoint['optimizer'] = optimizer.state_dict() |
| 302 | torch.save(checkpoint, "saved.pth") |
| 303 | """ |
| 304 | state_dict = {} |
| 305 | state_dict['loss_scaler'] = self.loss_scaler |
| 306 | state_dict['dynamic_loss_scale'] = self.dynamic_loss_scale |
| 307 | state_dict['overflow'] = self.overflow |
| 308 | state_dict['first_closure_call_this_step'] = self.first_closure_call_this_step |
| 309 | state_dict['optimizer_state_dict'] = self.optimizer.state_dict() |
| 310 | state_dict['fp32_from_fp16'] = self.fp32_from_fp16_groups |
| 311 | return state_dict |
| 312 | |
| 313 | def load_state_dict(self, state_dict): |
| 314 | """ |
no outgoing calls
no test coverage detected