beanmachine.ppl.world.variable module

class beanmachine.ppl.world.variable.Variable(value: torch.Tensor, distribution: torch.distributions.distribution.Distribution, parents: Set[beanmachine.ppl.model.rv_identifier.RVIdentifier] = <factory>, children: Set[beanmachine.ppl.model.rv_identifier.RVIdentifier] = <factory>)

Bases: object

Primitive used for maintaining metadata of random variables. Usually used in conjunction with World during inference.

value

Sampled value of random variable

Type

torch.Tensor

distribution

Distribution random variable was sampled from

Type

torch.distributions.Distribution

parents

Set containing the RVIdentifiers of the parents of the random variable

Type

set

children

Set containing the RVIdentifiers of the children of the random variable

Type

set

children: Set[beanmachine.ppl.model.rv_identifier.RVIdentifier]
distribution: torch.distributions.distribution.Distribution
property log_prob: torch.Tensor

Returns The logprob of the value of the value given the distribution.

parents: Set[beanmachine.ppl.model.rv_identifier.RVIdentifier]
replace(**changes) beanmachine.ppl.world.variable.Variable

Return a new Variable object with fields replaced by the changes

value: torch.Tensor