Identity matrix weights intialization

How can I initialize the weights of a linear layer with identity matrix?

1 Like
l = nn.Linear(3,3)
l.weight.data.copy_(torch.eye(3))
6 Likes