Marginalized responses¶
The score of a marginalize block holds the density of the block's responses with the latent summed
out (response laws).
MarginalizedResponse is the law such a response is drawn from when a run is given no value for it,
bound to the values of one run. draw_classes draws the latents of nested grouped blocks jointly
from the GroupLevel of each.
marginal
¶
Responses whose density a marginalized score carries.
A marginalize block scores its responses with the latent summed out,
so a response of the block adds no density of its own to the joint. The
response still has a law. MarginalizedResponse is that law at the values
of one run: it draws the response with the latent drawn too, and gives
the distribution of each row with the latent summed out, whose mean is
the class-weighted mean of the row.
GroupLevel and draw_classes state how the latents of nested grouped
blocks are drawn jointly, given what has already been bound.
MarginalizedResponse
¶
MarginalizedResponse(declared: MarginalizedFactor, law: ResponseLaw, environment: Environment)
Bases: ContinuousMorphism
A marginalized block's response law, bound to one run's values.
| PARAMETER | DESCRIPTION |
|---|---|
declared
|
The response's declared morphism, which scores nothing.
TYPE:
|
law
|
How the response is distributed given an environment.
TYPE:
|
environment
|
The values of one run the law reads.
TYPE:
|
Source code in src/quivers/continuous/marginal.py
support
property
¶
support: Constraint
The support of the response family.
| RETURNS | DESCRIPTION |
|---|---|
Constraint
|
The declared family's support. |
rsample
¶
Draw the latent and then the response.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
The step's input, which the law does not read.
TYPE:
|
sample_shape
|
Leading independent sampling dimensions. |
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Draws of every row, |
Source code in src/quivers/continuous/marginal.py
rsample_event
¶
rsample_event(x: Tensor, sample_shape: Size, event: BoundEvent | None) -> Tensor
Draw the response on its declared truncation interval.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
The step's input, which the law does not read.
TYPE:
|
sample_shape
|
Leading independent sampling dimensions.
TYPE:
|
event
|
The recording roles, which the law holds itself.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Draws of every row. |
Source code in src/quivers/continuous/marginal.py
sampling_distribution
¶
sampling_distribution(x: Tensor, event: BoundEvent | None = None) -> Distribution
The law of each row with the block's latents summed out.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
The step's input, which the law does not read.
TYPE:
|
event
|
The recording roles, which the law holds itself.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Distribution
|
One distribution per row, given the values the block does not sum out and no response. |
Source code in src/quivers/continuous/marginal.py
log_prob
¶
log_prob_event
¶
log_prob_event(x: Tensor, y: Tensor, event: BoundEvent) -> Tensor
Score nothing: the block's score step holds the recorded events.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
The step's input.
TYPE:
|
y
|
The recorded response.
TYPE:
|
event
|
The recording roles.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Zero. |
Source code in src/quivers/continuous/marginal.py
GroupLevel
didactic-model
¶
GroupLevel(*, log_weights: Tensor = field(opaque=True, extras=OPAQUE_BY_IDENTITY), parent: Tensor | None = field(default=None, opaque=True, extras=OPAQUE_BY_IDENTITY))
Bases: ValueModel
One block of a nest of grouped blocks, at one run's values.
| PARAMETER | DESCRIPTION |
|---|---|
log_weights
|
The log weight of each unit and class,
TYPE:
|
parent
|
The enclosing block's unit each unit belongs to,
TYPE:
|
draw_classes
¶
draw_classes(levels: Sequence[GroupLevel]) -> tuple[Tensor, ...]
Draw the classes of a nest of grouped blocks jointly.
The evidence of each inner unit is summed over its class and added to the class weights of the unit that encloses it, from the innermost block out. The classes are then drawn from the outermost block in, each given the classes of the units that enclose it. The draw is exact: the classes of the innermost units have the joint distribution that the weights of all the levels define.
| PARAMETER | DESCRIPTION |
|---|---|
levels
|
The blocks, outermost first.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Tensor, ...]
|
For each block, the class of the unit of it that encloses each unit
of the innermost block, |