Utils
Define utility functions for use in other modules.
DenseReluNetwork(out_dim, hidden_layers, hidden_dim)
Create a dense neural network with Relu after hidden layers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
out_dim |
int
|
The output dimension. |
required |
hidden_layers |
int
|
The number of hidden layers |
required |
hidden_dim |
int
|
The dimension of the hidden layers |
required |
Returns:
Name | Type | Description |
---|---|---|
init_fun |
function
|
The function that initializes the network. Note that this is the init_function defined in the Jax stax module, which is different from the functions of my InitFunction class. |
forward_fun |
function
|
The function that passes the inputs through the neural network. |
Source code in pzflow/utils.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
RationalQuadraticSpline(inputs, W, H, D, B, periodic=False, inverse=False)
Apply rational quadratic spline to inputs and return outputs with log_det.
Applies the piecewise rational quadratic spline developed in [1].
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs |
jnp.ndarray
|
The inputs to be transformed. |
required |
W |
jnp.ndarray
|
The widths of the spline bins. |
required |
H |
jnp.ndarray
|
The heights of the spline bins. |
required |
D |
jnp.ndarray
|
The derivatives of the inner spline knots. |
required |
B |
float
|
Range of the splines. Outside of (-B,B), the transformation is just the identity. |
required |
inverse |
bool
|
If True, perform the inverse transformation. Otherwise perform the forward transformation. |
False
|
periodic |
bool
|
Whether to make this a periodic, Circular Spline [2]. |
False
|
Returns:
Name | Type | Description |
---|---|---|
outputs |
jnp.ndarray
|
The result of applying the splines to the inputs. |
log_det |
jnp.ndarray
|
The log determinant of the Jacobian at the inputs. |
References
[1] Conor Durkan, Artur Bekasov, Iain Murray, George Papamakarios. Neural Spline Flows. arXiv:1906.04032, 2019. https://arxiv.org/abs/1906.04032 [2] Rezende, Danilo Jimenez et al. Normalizing Flows on Tori and Spheres. arxiv:2002.02428, 2020 http://arxiv.org/abs/2002.02428
Source code in pzflow/utils.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
|
build_bijector_from_info(info)
Build a Bijector from a Bijector_Info object
Source code in pzflow/utils.py
11 12 13 14 15 16 17 18 19 |
|
gaussian_error_model(key, X, Xerr, nsamples)
Default Gaussian error model were X are the means and Xerr are the stds.
Source code in pzflow/utils.py
52 53 54 55 56 57 58 59 60 61 |
|
sub_diag_indices(inputs)
Return indices for diagonal of 2D blocks in 3D array
Source code in pzflow/utils.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|