r"""Returns a dictionary containing whole states of the module.
(self, rst=None, prefix="", keep_var=False)
| 454 | return offset |
| 455 | |
| 456 | def state_dict(self, rst=None, prefix="", keep_var=False): |
| 457 | r"""Returns a dictionary containing whole states of the module.""" |
| 458 | _rst = self._state_dict(rst=rst, prefix=prefix, keep_var=keep_var) |
| 459 | rst = OrderedDict() |
| 460 | XNorm_typeclass = _get_XNorm_typeclass() |
| 461 | for (module_type, k), v in _rst.items(): |
| 462 | # for performance reasons, parameters in XNorm (e.g., BatchNorm2d) are 4-dim tensors, |
| 463 | # however they will be reshaped to 1-dim tensors before returned by `statr_dict()` |
| 464 | if issubclass(module_type, XNorm_typeclass): |
| 465 | v = v.reshape(-1) |
| 466 | rst[k] = v |
| 467 | return rst |
| 468 | |
| 469 | def _state_dict(self, rst=None, prefix="", keep_var=False): |
| 470 | r"""Returns a dictionary containing whole states of the module.""" |