import torch class Model(torch.nn.Module): pass model = Model() model.c_one = torch.nn.ModuleDict( dict( emb = torch.nn.Embedding(10, 3), drp = torch.nn.Dropout (0.15 ) )) model.c_two = torch.nn.Linear( 15, 7, bias=False) for c in model.children(): print(c) print('----------------')
named_children()
and apply()