How to add your costume regulator function in TensorFlow?

Hi,

I would like to add a costume regularizer for my loss function in TF. Is there any straightforward way to do that?
My constraint would be:
My loss
s.t sum of each row of weight matrix = 1.

Thanks

Hi @Azim_Dehghani_Amirab,

Sorry for the delay in response.
Yes, you can add custom regularizers by implementing it as a subclass of tf.keras.regularizers.Regularizer.For more details please check this official documentation of custom regularizers and I’ve also added a sample gist implementation for your reference.

Thank You.