Sampleables¶
A torch morphism at an input, as the kernel's sampleable.
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
dataclass
¶
TorchSampleable(morphism: ContinuousMorphism, input: Tensor, declared: ContinuousMorphism | None = None)
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:
|
__post_init__
¶
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. |