Why does model.named_children() not return nn.Parameter?

Hi,

I observed that model.parameters() returns nn.Parameter, but model.children() (and also named_children()) does not return nn.Parameter. Is this intended? I think model.children() should also return nn.Parameter.

I wrote a simple reproducible code below. I tested the code in v1.0.0.

Thanks,

import torch.nn as nn


class MyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc = nn.Linear(512, 512)
        self.alpha = nn.Parameter(torch.tensor(1.0))

    def forward(self, x):
        return self.alpha * self.fc(x)

model = MyModel()

print(list(model.named_children())) # this retuns only self.fc

Hi,

The doc is maybe not super clear but .children() returns all the nn.Modules that are fields of this one. parameters() will return the nn.Parameter.