Set the parameters of the optimizer object from a dictionary
(self, hparam_dict=None, cache_dict=None)
| 35 | return deepcopy(self) |
| 36 | |
| 37 | def set_params(self, hparam_dict=None, cache_dict=None): |
| 38 | """Set the parameters of the optimizer object from a dictionary""" |
| 39 | from ..initializers import SchedulerInitializer |
| 40 | |
| 41 | if hparam_dict is not None: |
| 42 | for k, v in hparam_dict.items(): |
| 43 | if k in self.hyperparameters: |
| 44 | self.hyperparameters[k] = v |
| 45 | if k == "lr_scheduler": |
| 46 | self.lr_scheduler = SchedulerInitializer(v, lr=None)() |
| 47 | |
| 48 | if cache_dict is not None: |
| 49 | for k, v in cache_dict.items(): |
| 50 | if k in self.cache: |
| 51 | self.cache[k] = v |
| 52 | |
| 53 | @abstractmethod |
| 54 | def update(self, param, param_grad, param_name, cur_loss=None): |
nothing calls this directly
no test coverage detected