Advanced
gpplus.means.advanced_means.CompositeMean
¤
Bases: Mean
A mean function that applies a user-provided transformation module to the input. The transformation is expected to yield a single-dimensional output (shape (batch_size, 1) or (batch_size,)) which represents the mean.
This can be any valid callable or nn.Module, including: - Polynomial feature expansions - Small neural networks - Other custom transforms
Unlike a typical 'base_mean', this class just returns the output of the provided transformation.
Source code in gpplus/means/advanced_means.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 | |
input_transform = input_transform
instance-attribute
¤
__init__(input_transform)
¤
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_transform
|
callable or Module
|
A user-defined transformation that takes x of shape (batch_size, input_dim) and returns a single-dimensional output (batch_size,). |
required |
Source code in gpplus/means/advanced_means.py
24 25 26 27 28 29 30 31 32 | |
forward(x)
¤
Applies the user-provided transformation and returns its output as the mean.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input of shape (batch_size, input_dim). |
required |
Returns:
| Type | Description |
|---|---|
|
torch.Tensor: Mean predictions of shape (batch_size,). |
Source code in gpplus/means/advanced_means.py
34 35 36 37 38 39 40 41 42 43 44 45 46 | |
gpplus.means.advanced_means.NeuralMean
¤
Bases: Mean
A mean function that builds its own MLP internally using InputTransformNet.
The final layer of InputTransformNet must have dims=1, so that the
network outputs a single scalar per data point.
For example, a valid layer_config might look like:
layer_config = {
0: {"dims": 64, "activation": nn.ReLU},
1: {"dims": 32, "activation": nn.ReLU},
2: {"dims": 1, "activation": nn.Identity},
}
This ensures the network outputs shape (batch_size, 1), which we then squeeze to (batch_size,).
Source code in gpplus/means/advanced_means.py
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 | |
transform_net = InputTransformNet(input_dim, layer_config)
instance-attribute
¤
__init__(input_dim, layer_config)
¤
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_dim
|
int
|
Number of input features. |
required |
layer_config
|
dict
|
Configuration for each layer, where the last layer must have 'dims' == 1. |
required |
Source code in gpplus/means/advanced_means.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
forward(x)
¤
Computes the mean by passing inputs through the internal network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input of shape (batch_size, input_dim). |
required |
Returns:
| Type | Description |
|---|---|
|
torch.Tensor: Mean predictions of shape (batch_size,). |
Source code in gpplus/means/advanced_means.py
89 90 91 92 93 94 95 96 97 98 99 100 | |