Skip to content

nn.init.eye_ sets requires_grad to False on tensors #8692

@zou3519

Description

@zou3519

repro:

import torch.nn as nn
L = nn.Linear(5,5)
nn.init.eye_(L.weight)
print(L.weight.requires_grad)  # False

Initially reported from https://discuss.pytorch.org/t/since-0-4-using-nn-init-eye-disables-gradient/19999/2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions