geometric_kernels.utils.product¶
Utilities for dealing with product spaces and product kernels.
Module Contents¶
- geometric_kernels.utils.product.make_product(xs)[source]¶
Embed a list of elements of factor spaces into the product space. Assumes that elements are batched along the first dimension.
- Parameters:
xs (beartype.typing.List[lab.Numeric]) – List of the batches of elements, each of the shape [N, <axes(space)>], where <axes(space)> is the shape of the elements of the respective space.
- Returns:
An [N, D]-shaped array, a batch of product space elements, where D is the sum, over all factor spaces, of prod(<axes(space)>).
- Return type:
lab.Numeric
- geometric_kernels.utils.product.params_to_params_list(number_of_factors, params)[source]¶
Takes a dictionary of parameters of a product kernel and returns a list of dictionaries of parameters for the factor kernels. The shape of “lengthscale” should be the same as the shame of “nu”, and the length of both should be either 1 or equal to number_of_factors.
- Parameters:
number_of_factors (int) – Number of factors in the product kernel.
params (beartype.typing.Dict[str, lab.Numeric]) – Parameters of the product kernel.
- Return type:
beartype.typing.List[beartype.typing.Dict[str, lab.Numeric]]
- geometric_kernels.utils.product.project_product(x, dimension_indices, element_shapes, element_dtypes)[source]¶
Project an element of the product space onto each factor. Assumes that elements are batched along the first dimension.
- Parameters:
x (lab.Numeric) – An [N, D]-shaped array, a batch of N product space elements.
dimension_indices (beartype.typing.List[beartype.typing.List[int]]) – Determines how a product space element x is to be mapped to inputs xi of the factor kernels. xi are assumed to be equal to x[dimension_indices[i]], possibly up to a reshape. Such a reshape might be necessary to accommodate the spaces whose elements are matrices rather than vectors, as determined by element_shapes.
element_shapes (beartype.typing.List[beartype.typing.List[int]]) – Shapes of the elements in each factor. Can be obtained as properties space.element_shape of any given factor space.
element_dtypes (beartype.typing.List[lab.DType]) – Abstract lab data types of the elements in each factor. Can be obtained as properties space.element_dtype of any given factor space.
- Returns:
A list of the batches of elements xi in factor spaces, each of the shape [N, *element_shapes[i]].
- Return type:
beartype.typing.List[lab.Numeric]