Function¶
- class probnum.functions.Function(input_shape, output_shape=())[source]¶
Bases:
ABC
Callable with information about the shape of expected in- and outputs.
This class represents a, uni- or multivariate, scalar- or tensor-valued, mathematical function. Hence, the call method should not have any observable side-effects. Instances of this class can be added and multiplied by a scalar, which means that they are elements of a vector space.
- Parameters
input_shape (ShapeLike) – Input shape.
output_shape (ShapeLike) – Output shape.
- Return type
None
See also
LambdaFunction
Define a
Function
from an anonymous function.Zero
Zero function.
Attributes Summary
Syntactic sugar for
len(input_shape)
.Shape of the function's input.
Syntactic sugar for
len(output_shape)
.Shape of the function's output.
Methods Summary
__call__
(x)Evaluate the function at a given input.
Attributes Documentation
- input_ndim¶
Syntactic sugar for
len(input_shape)
.
- input_shape¶
Shape of the function’s input.
For a scalar-input function, this is an empty tuple.
- output_ndim¶
Syntactic sugar for
len(output_shape)
.
- output_shape¶
Shape of the function’s output.
For scalar-valued function, this is an empty tuple.
Methods Documentation
- __call__(x)[source]¶
Evaluate the function at a given input.
The function is vectorized over the batch shape of the input.
- Parameters
x (ArrayLike) – shape=
batch_shape +
input_shape
– (Batch of) input(s) at which to evaluate the function.- Returns
shape=
batch_shape +
output_shape
– Function evaluated at the given (batch of) input(s).- Return type
fx
- Raises
ValueError – If the shape of
x
does not matchinput_shape
along its last dimensions.