Interpretations¶
Interpreter¶
-
reinterpret
(x)[source]¶ Overloaded reinterpretation of a deferred expression.
This handles a limited class of expressions, raising
ValueError
in unhandled cases.Parameters: x (A funsor or data structure holding funsors.) – An input, typically involving deferred Funsor
s.Returns: A reinterpreted version of the input. Raises: ValueError
-
class
StatefulInterpretation
[source]¶ Bases:
object
Base class for interpreters with instance-dependent state or parameters.
Example usage:
class MyInterpretation(StatefulInterpretation): def __init__(self, my_param): self.my_param = my_param @MyInterpretation.register(...) def my_impl(interpreter_state, cls, *args): my_param = interpreter_state.my_param ... with interpretation(MyInterpretation(my_param=0.1)): ...
-
classmethod
dispatch
(key, *args)¶
-
registry
= <funsor.registry.KeyedRegistry object>¶
-
classmethod
-
exception
PatternMissingError
[source]¶ Bases:
NotImplementedError
Monte Carlo¶
-
class
MonteCarlo
(*, rng_key=None, **sample_inputs)[source]¶ Bases:
funsor.interpreter.StatefulInterpretation
A Monte Carlo interpretation of
Integrate
expressions. This falls back to the previous interpreter in other cases.Parameters: rng_key – -
classmethod
dispatch
(key, *args)¶
-
registry
= <funsor.registry.KeyedRegistry object>¶
-
classmethod