|
16 | 16 | @serializable(package="bayesflow.adapters")
|
17 | 17 | class Constrain(ElementwiseTransform):
|
18 | 18 | """
|
19 |
| - Constrains neural network predictions of a data variable to specificied bounds. |
20 |
| - |
21 |
| - Parameters: |
22 |
| - String containing the name of the data variable to be transformed e.g. "sigma". See examples below. |
| 19 | + Constrains neural network predictions of a data variable to specificied bounds. |
23 | 20 |
|
24 |
| - Named Parameters: |
| 21 | + Parameters: |
| 22 | + String containing the name of the data variable to be transformed e.g. "sigma". See examples below. |
| 23 | +
|
| 24 | + Named Parameters: |
25 | 25 | lower: Lower bound for named data variable.
|
26 | 26 | upper: Upper bound for named data variable.
|
27 |
| - method: Method by which to shrink the network predictions space to specified bounds. Choose from |
| 27 | + method: Method by which to shrink the network predictions space to specified bounds. Choose from |
28 | 28 | - Double bounded methods: sigmoid, expit, (default = sigmoid)
|
29 | 29 | - Lower bound only methods: softplus, exp, (default = softplus)
|
30 | 30 | - Upper bound only methods: softplus, exp, (default = softplus)
|
31 |
| - |
32 | 31 |
|
33 | 32 |
|
34 |
| - Examples: |
35 |
| - Let sigma be the standard deviation of a normal distribution, then sigma should always be greater than zero. |
36 | 33 |
|
37 |
| - Useage: |
| 34 | + Examples: |
| 35 | + Let sigma be the standard deviation of a normal distribution, |
| 36 | + then sigma should always be greater than zero. |
| 37 | +
|
| 38 | + Useage: |
38 | 39 | adapter = (
|
39 | 40 | bf.Adapter()
|
40 | 41 | .constrain("sigma", lower=0)
|
41 | 42 | )
|
42 | 43 |
|
43 |
| - Suppose p is the parameter for a binomial distribution where p must be in [0,1] then we would constrain the neural network to estimate p in the following way |
| 44 | + Suppose p is the parameter for a binomial distribution where p must be in [0,1] |
| 45 | + then we would constrain the neural network to estimate p in the following way. |
44 | 46 |
|
45 |
| - Usage: |
| 47 | + Usage: |
46 | 48 | adapter = (
|
47 | 49 | bf.Adapter()
|
48 | 50 | .constrain("p", lower=0, upper=1, method = "sigmoid")
|
|
0 commit comments