You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add items() method to nn.Module for state_dict iteration
Add items() method to nn.Module that returns an enumerator of (name, tensor)
tuples from the module's state_dict. This enables easy iteration over all
parameters and persistent buffers, consistent with the existing items()
pattern in ModuleDict and ParameterDict.
This addresses the core request in issue #1474 by providing the items()
API needed for model merging workflows (averaging parameters between
models using state_dict + load_state_dict).
Changes:
- Add virtual items() method to Module class
- Add 'new' keyword to ModuleDict.items() and ParameterDict.items() to
properly hide the base class method (different return types)
- Add tests for items() on simple and nested modules
- Add test demonstrating the model merge pattern from the issue
Closes#1474
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments