Thank you so much! The penalty approach makes a lot of sense!
I figure out that what I want on the weights W can be stated in the following way:
Suppose the weight or kernel matrix is a 3 by 4 matrix W, and its elements are W_ij
I would like for each column j, there is one and only one nonzero W_ij, and W_ij = 1.
What would be a good way to implement this requirement?
One possible solution I can think of is to put the following constraints using the penalty approach you mentioned:
W_1j + W_2j + W_3j = 1 for all j = 1,2,3,4
and
W_ij * (1-W_ij) = 0, for all i, j
But is it possible to implement these constraints directly? Or is there any better way to require the property (in bold) that I want?
If this is not possible in Pytorch, can TensorFlow do it?