How can I do any constraints in the same layer?

Dears,
I want to do two weights constraints in the same layer. My weights should be non-negatives and w_1 > w_2 > w_3 > … > w_N. I would like to use tf.keras.constraints. Did you do this?

Regards.

Probably you could try with the custom constrain section:

Thanks Back. But my question is how to impose the constraints w_1 > w_2 > w_3 > … > w_N? Do you know?

Regards.

If you check the other “canned” constrains you can see that you need to just manipulate the weights that are not respecting your constrain.

In your case I suggest to check this implementation as a baseline to retrieve the indexes of the weights that you want to manipulate:

1 Like