'How to add trainable variable in Python Tensorflow
I would like to add trainable parameter 'p' into my neural network model coded by Python tensorflow. The parameter 'p' should range between 0 and 1. It can be ranged between 0 and 1, transformed by sigmoid function (e.g. p = 1/(1 + exp(-pi)) and in this case, values obtained from sigmoid function should be normally distributed. Please let me know if you have any ideas to solve this problem. Thank you.
Solution 1:[1]
You probably want to do tensorflow layers subclassing and add your p trainable variable through self.add_weight in your subclass.
Applying a sigmoid is one way to have your value between 0 and 1. Another way is through the constraint parameter of self.add_weight (It will clip your value between 0 and 1).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Loris Pilotto |
