Sampleables¶
A MonadicProgram step draws from a ContinuousMorphism at an input tensor, and the Quivers Indexed Effect Core (QIEC) request
Random.sample takes one sampleable value. TorchSampleable wraps the pair as that value
(sample sites). It offers the sampling
and scoring interface the prelude handlers use, and keeps the morphism and the input for a
strategy or a trace to read.
sites
¶
Host sampleables: a torch morphism applied to an input, as a distribution.
A MonadicProgram step draws from a ContinuousMorphism at an input
tensor. The kernel's Random.sample request takes a sampleable value,
so the pair is wrapped as one: TorchSampleable offers the sampling
and scoring interface the prelude handlers use and keeps the morphism
and input a strategy or a trace may want to read.
TorchSampleable
¶
TorchSampleable(*, morphism: ContinuousMorphism, input: Tensor, declared: ContinuousMorphism | None = None, raw_morphism: ContinuousMorphism | None = None)
Bases: ValueModel
A morphism applied to an input, offered to the kernel as a sampleable.
| PARAMETER | DESCRIPTION |
|---|---|
morphism
|
The morphism the site draws from, under whatever parameters the
run's
TYPE:
|
input
|
The input tensor the morphism is conditioned on, carrying the batch axis.
TYPE:
|
declared
|
The morphism as the program declares it, which a trace records and a strategy reads the family of; the drawing morphism itself when no parameter store rebinds it.
TYPE:
|
raw_morphism
|
The parameterized response distribution before likelihood weighting or observation subsampling, used for raw likelihood extraction.
TYPE:
|
Construct a sampleable holding live runtime references by identity.
| PARAMETER | DESCRIPTION |
|---|---|
morphism
|
The morphism used for sampling and scoring.
TYPE:
|
input
|
The tensor conditioning the morphism.
TYPE:
|
declared
|
The declared site morphism, defaulting to the sampling morphism.
TYPE:
|
raw_morphism
|
The unweighted response morphism, defaulting to the sampling morphism.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValidationError
|
If the runtime fields have incompatible types. |
Source code in src/quivers/effects/sites.py
rsample
¶
rsample() -> Tensor
Draw a reparameterised sample.
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
One draw per batch row. |
log_prob
¶
parameters
¶
parameters() -> dict[str, Tensor]
The distribution parameters the morphism computes at the input.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Tensor]
|
The named parameters of the torch distribution the morphism
builds, or |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the morphism exposes neither a distribution builder nor a location-scale pair. |
Source code in src/quivers/effects/sites.py
raw_log_prob_pointwise
¶
Read the response density before likelihood weighting or subsampling.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The observed response values.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Raw log densities, one per observation row when the family has a plate, with event dimensions reduced. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the site is the response of a marginalized block, whose density the units of the block's score hold. |