MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / children

Method children

python/oneflow/nn/modules/module.py:637–659  ·  view source on GitHub ↗

r""" children() -> Iterator["Module"] Returns an iterator over immediate children modules. Yields: Module: a child module Example:: >>> import oneflow.nn as nn >>> l1 = nn.Linear(2, 2) >>> l2 = nn

(self)

Source from the content-addressed store, hash-verified

635 yield elem
636
637 def children(self) -> Iterator["Module"]:
638 r"""
639 children() -> Iterator["Module"]
640
641 Returns an iterator over immediate children modules.
642
643 Yields:
644 Module: a child module
645
646 Example::
647
648 >>> import oneflow.nn as nn
649 >>> l1 = nn.Linear(2, 2)
650 >>> l2 = nn.Linear(2, 2)
651 >>> net = nn.Sequential(l1, l2)
652 >>> for idx, m in enumerate(net.children()):
653 ... print(idx, '->', m)
654 0 -> Linear(in_features=2, out_features=2, bias=True)
655 1 -> Linear(in_features=2, out_features=2, bias=True)
656
657 """
658 for (name, module) in self.named_children():
659 yield module
660
661 def named_children(self) -> Iterator[Tuple[str, "Module"]]:
662 r"""

Callers 5

trainMethod · 0.95
_applyMethod · 0.95
applyMethod · 0.95
_to_memory_formatMethod · 0.95
test_module_setattrMethod · 0.80

Calls 1

named_childrenMethod · 0.95

Tested by 1

test_module_setattrMethod · 0.64