trieste.data
#
This module contains utilities for Observer
data.
Module Contents#
- class Dataset[source]#
Container for the query points and corresponding observations from an
Observer
.- observations: trieste.types.TensorType[source]#
The observed output of the
Observer
for each query point.
- __post_init__() None [source]#
- Raises:
ValueError (or InvalidArgumentError) – If
query_points
orobservations
have rank less than two, or they have unequal shape in any but their last dimension.
- __add__(rhs: Dataset) Dataset [source]#
Return the
Dataset
whose query points are the result of concatenating the query_points in eachDataset
along the zeroth axis, and the same for the observations. For example:>>> d1 = Dataset( ... tf.constant([[0.1, 0.2], [0.3, 0.4]]), ... tf.constant([[0.5, 0.6], [0.7, 0.8]]) ... ) >>> d2 = Dataset(tf.constant([[0.9, 1.0]]), tf.constant([[1.1, 1.2]])) >>> (d1 + d2).query_points <tf.Tensor: shape=(3, 2), dtype=float32, numpy= array([[0.1, 0.2], [0.3, 0.4], [0.9, 1. ]], dtype=float32)> >>> (d1 + d2).observations <tf.Tensor: shape=(3, 2), dtype=float32, numpy= array([[0.5, 0.6], [0.7, 0.8], [1.1, 1.2]], dtype=float32)>
- Parameters:
rhs – A
Dataset
with the same shapes as this one, except in the zeroth dimension, which can have any size.- Returns:
The result of concatenating the
Dataset
s.- Raises:
InvalidArgumentError – If the shapes of the query_points in each
Dataset
differ in any but the zeroth dimension. The same applies for observations.
- __len__() tensorflow.Tensor [source]#
- Returns:
The number of query points, or equivalently the number of observations.
- astuple() tuple[trieste.types.TensorType, trieste.types.TensorType] [source]#
Note: Unlike the standard library function dataclasses.astuple, this method does not deepcopy the attributes.
- Returns:
A 2-tuple of the
query_points
andobservations
.
- check_and_extract_fidelity_query_points(query_points: trieste.types.TensorType, max_fidelity: int | None = None) tuple[trieste.types.TensorType, trieste.types.TensorType] [source]#
Check whether the final column of a tensor is close enough to ints to be reasonably considered to represent fidelities.
The final input column of multi-fidelity data should be a reference to the fidelity of the query point. We cannot have mixed type tensors, but we can check that thhe final column values are suitably close to integers.
- Parameters:
query_points – Data to check final column of.
- Raise:
ValueError: If there are not enough columns to be multifidelity data
- Raises:
InvalidArgumentError – If any value in the final column is far from an integer
- Returns:
Query points without fidelity column and the fidelities of each of the query points
- split_dataset_by_fidelity(dataset: Dataset, num_fidelities: int) Sequence[Dataset] [source]#
Split dataset into individual datasets without fidelity information
- Parameters:
dataset – Dataset for which to split fidelities
num_fidlities – Number of fidelities in the problem (not just dataset)
- Returns:
Ordered list of datasets with lowest fidelity at index 0 and highest at -1
- get_dataset_for_fidelity(dataset: Dataset, fidelity: int) Dataset [source]#
Get a dataset with only the specified fidelity of data in
- Parameters:
dataset – The dataset from which to extract the single fidelity data
fidelity – The fidelity to extract the data for
- Returns:
Dataset with a single fidelity and no fidelity column
- add_fidelity_column(query_points: trieste.types.TensorType, fidelity: int) trieste.types.TensorType [source]#
Add fidelity column to query_points without fidelity data
- Parameters:
query_points – query points without fidelity to add fidelity column to
fidelity – fidelity to populate fidelity column with
- Returns:
TensorType of query points with fidelity column added