Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save n0obcoder/37873ede4f6b129cc502dd55be4e4976 to your computer and use it in GitHub Desktop.

Select an option

Save n0obcoder/37873ede4f6b129cc502dd55be4e4976 to your computer and use it in GitHub Desktop.
for name, child in model.named_children():
print('name: ', name)
print('isinstance(child, nn.Module): ', isinstance(child, nn.Module))
print('isinstance(child, nn.Parameter): ', isinstance(child, nn.Parameter))
print('isinstance(child, torch.Tensor) ', isinstance(child, torch.Tensor))
print('=====')
# Also try model.children(). It doesn't return the name of the children, but the children (nn.Module objects)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment