The
torch.nn.Module.named_parameters() method returns an iterator that yields tuples containing both the name and the parameter tensor for each parameter in the module.- Iterator-based: Returns an iterator rather than a list, making it memory-efficient for large models
- Hierarchical naming: Parameter names reflect the module hierarchy using dot notation (e.g.,
layer1.weight)
- Recursive by default: Includes parameters from all submodules unless specified otherwise
Selective Parameter Freezing
Module — PyTorch 2.2 documentation
Modules can also contain other Modules, allowing to nest them in
a tree structure. You can assign the submodules as regular attributes:
https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.named_parameters

Seonglae Cho