In my work, I need to train a parameter to represent the ratio in [0,1].
I have tried to pass this parameter through sigmoid, tanh, clamp functions.
...
self.register_parameter('ratio',nn.Parameter(torch.FloatTensor([ratio_init])))
...
ratio = getattr(self, 'ratio')
ratio = F.sigmoid(ratio)
parameter = ratio*some_parameter_1 + (1-ratio)*some_parameter_2

I train this network and hope to get the best ratio.
I want to ask whether my method has some problems?
Or pytorch has other method to restrict the trainable ratio between [0,1]