Bases: Objective
Computes the A-optimal design metric.
A-optimality aims to minimize the trace of the
covariance matrix \(Tr(K(X, X))\). Since optimization algorithms typically
minimize a function, this objective returns the negative trace, which
is then maximized.
Source code in sgptools/objectives.py
| class AOptimal(Objective):
"""
Computes the A-optimal design metric.
A-optimality aims to minimize the trace of the
covariance matrix $Tr(K(X, X))$. Since optimization algorithms typically
minimize a function, this objective returns the negative trace, which
is then maximized.
"""
def __call__(self, X: tf.Tensor) -> tf.Tensor:
"""
Computes the negative trace of the covariance matrix $-Tr(K(X, X))$.
Args:
X (tf.Tensor): The input points (e.g., sensing locations) for which
the objective is to be computed. Shape: (M, D).
Returns:
tf.Tensor: The computed A-optimal metric value.
Usage:
```python
import gpflow
import numpy as np
# Assume kernel is defined
# X_objective = np.random.rand(100, 2) # Not used by A-Optimal but required by base class
# kernel = gpflow.kernels.SquaredExponential()
# noise_variance = 0.1
a_optimal_objective = AOptimal(
X_objective=X_objective,
kernel=kernel,
noise_variance=noise_variance
)
X_sensing = tf.constant(np.random.rand(10, 2), dtype=tf.float64)
a_optimal_value = a_optimal_objective(X_sensing)
```
"""
# K(X, X)
K_X_X = self.kernel(X)
trace_K_X_X = tf.linalg.trace(self.jitter_fn(K_X_X))
return -trace_K_X_X
|
Computes the negative trace of the covariance matrix \(-Tr(K(X, X))\).
Parameters:
Name |
Type |
Description |
Default |
X
|
Tensor
|
The input points (e.g., sensing locations) for which
the objective is to be computed. Shape: (M, D).
|
required
|
Returns:
Type |
Description |
Tensor
|
tf.Tensor: The computed A-optimal metric value.
|
Usage
import gpflow
import numpy as np
# Assume kernel is defined
# X_objective = np.random.rand(100, 2) # Not used by A-Optimal but required by base class
# kernel = gpflow.kernels.SquaredExponential()
# noise_variance = 0.1
a_optimal_objective = AOptimal(
X_objective=X_objective,
kernel=kernel,
noise_variance=noise_variance
)
X_sensing = tf.constant(np.random.rand(10, 2), dtype=tf.float64)
a_optimal_value = a_optimal_objective(X_sensing)
Source code in sgptools/objectives.py
| def __call__(self, X: tf.Tensor) -> tf.Tensor:
"""
Computes the negative trace of the covariance matrix $-Tr(K(X, X))$.
Args:
X (tf.Tensor): The input points (e.g., sensing locations) for which
the objective is to be computed. Shape: (M, D).
Returns:
tf.Tensor: The computed A-optimal metric value.
Usage:
```python
import gpflow
import numpy as np
# Assume kernel is defined
# X_objective = np.random.rand(100, 2) # Not used by A-Optimal but required by base class
# kernel = gpflow.kernels.SquaredExponential()
# noise_variance = 0.1
a_optimal_objective = AOptimal(
X_objective=X_objective,
kernel=kernel,
noise_variance=noise_variance
)
X_sensing = tf.constant(np.random.rand(10, 2), dtype=tf.float64)
a_optimal_value = a_optimal_objective(X_sensing)
```
"""
# K(X, X)
K_X_X = self.kernel(X)
trace_K_X_X = tf.linalg.trace(self.jitter_fn(K_X_X))
return -trace_K_X_X
|