particles
Particle
Bases: Module
The Particle
class. This class is based on of the GPJax
ConjugatePosterior
.
It takes a kernel (instance of TreeKernel
), noise variance
(float), and jitter (float) as input. The jitter is used to
ensure that the covariance matrix is positive definite (avoiding
numerical instabilities in case of small eigenvalues).
In contrast to the ConjugatePosterior
class, the Particle
currently
has more limited features, specifically we
- do not support mean functions (that implies a zero mean function,
in use cases the data should be appropriately centered).
- do not support likelihoods other than Gaussian.
Attributes:
Name | Type | Description |
---|---|---|
kernel |
TreeKernel
|
The kernel defining the covariance function of the Gaussian
process. Must be a |
noise_variance |
Variable | NoiseParameter
|
The (observational) noise variance of the Gaussian process. Depending
on the value of the |
jitter |
ScalarFloat
|
The jitter term to ensure numerical stability of the covariance matrix. |
Source code in gallifrey/particles.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 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 |
|
__init__(kernel, noise_variance, trainable_noise_variance=False, jitter=1e-06)
Initialize the particle.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kernel
|
TreeKernel
|
The kernel defining the covariance function of the Gaussian
process. Must be a |
required |
noise_variance
|
ScalarFloat
|
The (observational) noise variance of the Gaussian process. |
required |
trainable_noise_variance
|
bool
|
Whether to treat the noise variance as a trainable parameter, by default False. |
False
|
jitter
|
float
|
The jitter term to ensure numerical stability of the covariance matrix, by default 1e-6. |
1e-06
|
Source code in gallifrey/particles.py
60 61 62 63 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 |
|
__str__()
Print a string representation of the particle.
Returns:
Type | Description |
---|---|
str
|
A string representation of the particle. |
Source code in gallifrey/particles.py
93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
display()
Display the particle.
Source code in gallifrey/particles.py
107 108 109 110 111 |
|
predictive_distribution(xpredict, data, latent=False)
Calculate the predictive distribution of the Gaussian process for the particle.
Inputs will be the points to predict and the training data that the GP gets conditioned on.
The distribution returned will be a MultivariateNormalFullCovariance
distribution from tensorflow_probability.substrates.jax.distributions
, see
https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/MultivariateNormalFullCovariance
If latent
is True, the predictive distribution of the latent
function is returned, i.e. the distribution of the function
values without the observational noise. If False, the predictive
distribution of the full data-generating model is returned, which
includes the observational noise
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xpredict
|
Float[Array, ' D']
|
The points to predict, as a 1D array. |
required |
data
|
Dataset
|
The training data that the GP is conditioned on,
must be a |
required |
latent
|
bool
|
Whether to return the predictive distribution of the latent function (without observational noise), by default False. |
False
|
Returns:
Type | Description |
---|---|
Distribution
|
A tensorflow probability distribution object representing
the predictive distribution of the Gaussian process. (Specifically,
a MultivariateNormalFullCovariance distribution from
|
Source code in gallifrey/particles.py
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 |
|
transform_particle_parameters(particle_state, kernel_prior, inverse=False)
Transform parameter of a particle state (kernel parameters and noise variance) based on the support mapping and bijectors.
This function is primarily used to transform the parameters between a constrained and unconstrained space.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
particle_state
|
State
|
The original particle state. |
required |
kernel_prior
|
KernelPrior
|
The kernel prior that contains the support mapping and bijectors. |
required |
inverse
|
ScalarBool
|
If True, the inverse transformation is applied, by default False. |
False
|
Returns:
Type | Description |
---|---|
State
|
The particle state with transformed parameters. |
Source code in gallifrey/particles.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
|