But then you ask about restricting the value of a Parameter itself. Let me assume
that you want to restrict the Parameter itself, rather than its gradient.
(Note that in your example, you are asking that m lie between 0.1 and 0.9, but
you are initializing it to 0.02 – outside of that range.)
My recommendation is to let your trainable Parameters be unrestricted, that is,
range from -inf to inf, and then map them to a derived variable that satisfies
your desired restriction. (This is because gradient-descent optimization doesn’t
work for optimizing constrained variables without additional complication.)
So in your case in your __init__() method I would do something like: