mr2.operators.LookupTableOp
- class mr2.operators.LookupTableOp[source]
Bases:
Operator[Unpack[Tin],tuple[Tensor]]Interpolated lookup-table operator.
This operator approximates a tensor-valued generating function on a regular rectangular grid and evaluates it by multilinear interpolation. It is intended as a surrogate for expensive signal models such as sequence- specific MRF simulations.
If
index_of_scaling_parameteris provided, that parameter is excluded from the lookup grid. The lookup table is then built for unit scale, and the interpolated result is multiplied by the scaling parameter in the forward pass.- __init__(generating_function: Callable[[Unpack[Tin]], tuple[Tensor]], parameter_ranges: Sequence[tuple[float, float, int]], index_of_scaling_parameter: int | None = None) None[source]
Initialize the lookup-table operator.
- Parameters:
generating_function (
Callable[[Unpack[TypeVarTuple]],tuple[Tensor]]) – Function mapping parameters to exactly one output tensor.parameter_ranges (
Sequence[tuple[float,float,int]]) – Regular rectangular grid specification for the non-scaling parameters. Each entry is(minimum, maximum, n_steps)and is interpreted viatorch.linspace(minimum, maximum, n_steps). Ifindex_of_scaling_parameteris notNone, the scaling parameter must be omitted from this list.index_of_scaling_parameter (
int|None, default:None) – Optional index of a multiplicative scaling parameter. If provided, the lookup table is built for unit scale and the forward pass multiplies the interpolated result by the supplied scaling tensor.
- __call__(*parameters: Unpack[Tin]) tuple[Tensor][source]
Evaluate the interpolated lookup table.
- Parameters:
*parameters (
Unpack[TypeVarTuple]) – Parameter tensors for the generating function. The tensors are broadcast to a common batch shape before interpolation. If a scaling parameter was configured at initialization, it is excluded from the lookup grid and applied multiplicatively to the interpolated unit-scale output.- Returns:
interpolated output tensor.
- forward(*parameters: Unpack[Tin]) tuple[Tensor][source]
Apply forward of LookupTableOp.
Note
Prefer calling the instance of the LookupTableOp as
operator(x)over directly calling this method.
- __add__(other: Operator[Unpack[Tin], Tout]) Operator[Unpack[Tin], Tout][source]
- __add__(other: Tensor | complex) Operator[Unpack[Tin], tuple[Unpack[Tin]]]
Operator addition.
Returns
lambda x: self(x) + other(x)if other is a operator,lambda x: self(x) + other*xif other is a tensor
- __matmul__(other: Operator[Unpack[Tin2], tuple[Unpack[Tin]]] | Operator[Unpack[Tin2], tuple[Tensor, ...]]) Operator[Unpack[Tin2], Tout][source]
Operator composition.
Returns
lambda x: self(other(x))
- __mul__(other: Tensor | complex) Operator[Unpack[Tin], Tout][source]
Operator multiplication with tensor.
Returns
lambda x: self(x*other)