Returns an iterable for key tensor pairs of the module, where ``key`` is the dotted path from this module to the tensor. :param prefix: prefix prepended to the keys. :param recursive: if ``True``, returns all tensors within this module, else only returns
(
self, prefix: Optional[str] = None, recursive: bool = True, **kwargs
)
| 310 | ) |
| 311 | |
| 312 | def named_tensors( |
| 313 | self, prefix: Optional[str] = None, recursive: bool = True, **kwargs |
| 314 | ) -> Iterable[Tuple[str, Tensor]]: |
| 315 | """ |
| 316 | Returns an iterable for key tensor pairs of the module, where |
| 317 | ``key`` is the dotted path from this module to the tensor. |
| 318 | |
| 319 | :param prefix: prefix prepended to the keys. |
| 320 | :param recursive: if ``True``, returns all tensors within this |
| 321 | module, else only returns tensors that are direct attributes |
| 322 | of this module. |
| 323 | """ |
| 324 | yield from self._flatten( |
| 325 | with_key=True, |
| 326 | prefix=prefix, |
| 327 | predicate=_is_tensor, |
| 328 | recursive=recursive, |
| 329 | **kwargs, |
| 330 | ) |
| 331 | |
| 332 | def children(self, **kwargs) -> "Iterable[Module]": |
| 333 | r"""Returns an iterable for all the submodules that are direct attributes of this |