svgp_trainer
SparseGPTrainer
Bases: BaseTrainer
Trains an SVGP model using specified parameters and early stopping.
Attributes:
Name | Type | Description |
---|---|---|
num_inducing_points |
int
|
Number of inducing points for the SVGP. |
model |
SVGP
|
The Stochastic Variational Gaussian Process model. |
likelihood |
gpytorch.likelihoods.GaussianLikelihood
|
The likelihood of the model. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
array-like
|
The input features. |
required |
y |
array-like
|
The target outputs. |
required |
num_inducing_points |
int
|
Number of inducing points to use in the SVGP model. |
100
|
sample_weights |
array-like
|
Sample weights for each data point. Defaults to None. |
required |
test_size |
float
|
Fraction of the dataset to be used as test data. Defaults to 0.2. |
required |
random_state |
int
|
Random seed for reproducible results. Defaults to 42. |
required |
num_epochs |
int
|
Maximum number of training epochs. Defaults to 50. |
required |
batch_size |
int
|
Batch size for training. Defaults to 256. |
required |
optimizer_fn_name |
str
|
Name of the optimizer to use. Defaults to "Adam". |
required |
lr |
float
|
Learning rate for the optimizer. Defaults to 0.01. |
required |
use_scheduler |
bool
|
Whether to use a learning rate scheduler. Defaults to False. |
required |
patience |
int
|
Number of epochs with no improvement before stopping training. Defaults to 10. |
required |
dtype |
torch.dtype
|
The dtype to use for input tensors. Defaults to torch.float32. |
required |
Source code in uncertaintyplayground/trainers/svgp_trainer.py
9 10 11 12 13 14 15 16 17 18 19 20 21 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 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 |
|
predict_with_uncertainty(X)
Predicts the mean and variance of the output distribution given input tensor X.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
tensor
|
Input tensor of shape (num_samples, num_features). |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple | A tuple of the mean and variance of the output distribution, both of shape (num_samples,). |
Source code in uncertaintyplayground/trainers/svgp_trainer.py
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 |
|