Hello, is there are any feature in pytorch that resembles tensorflow/python/keras/constraints, for example in keras it is possible to constraint the parameter values using:
tf.keras.constraints.non_neg(),
to avoid negative values, i know in pytorch you can apply function after the optimization step as suggested in:

  
    
    
    Set constraints on parameters or layers 
  
  
    Hi, are there any ways in Pytorch to set the range of parameters or values in each layer? For example, is it able to constrain the range of the linear product Y = WX to [-1, 1]? If not, how about limiting the range of the weight? 
I noticed in Karas, user can define this by setting constraints. Any equivalence in Pytorch? 
Thanks!
  



  
    
    
    Restrict range of variable during gradient descent 
  
  
    I would copy the code for the Adam optimizer and modify it to do what you want.
  


but this doesn’t seem the cleanest way to do it, i mean, it would be much better if you could register the constraint inside your model class, i know that torch.distributions.constraints module exists but i’m not sure it applies to my case, any hint on this?