How to constrict each column of weight matrix sum to 1

I have a linear layer which is nn.Linear(2000,50,bias=False). The weight matrix is 50x2000. I want to constrict each column of the weight matrix sum to 1. Specifically, w[0][0] + w[1][0] + … + w[49][0] = 1. How can I do this in pytorch ?

Did you try this?

Thank you. At first, I did not understand the answer in it. But now I get it.

1 Like