clipppy.stochastic.sampler¶
Module Contents¶
- class clipppy.stochastic.sampler.AbstractSampler¶
The base class for “samplers”: objects that dynamically (or not) generate values in a
Stochasticcontext.- abstract __call__(self)¶
An
AbstractSampleris called whenStochasticencounters one as a “specification”, and it is this method that has to be overridden in subclasses to supply the desired value.
- class clipppy.stochastic.sampler.ConcreteSampler¶
A base class for “true” samplers, i.e. that provide a value from Pyro.
- init :torch.Tensor¶
- support :torch.distributions.constraints.Constraint¶
- class clipppy.stochastic.sampler.Context(context: ContextManager, func_or_val: _ps_func_t, call: _ps_call_t = PseudoSampler.call)¶
The base class for “samplers”: objects that dynamically (or not) generate values in a
Stochasticcontext.- __call__(self, *args, **kwargs)¶
An
AbstractSampleris called whenStochasticencounters one as a “specification”, and it is this method that has to be overridden in subclasses to supply the desired value.
- class clipppy.stochastic.sampler.Deterministic¶
A
PseudoSamplerthat records the value viapyro.deterministic.- _func¶
- event_dim :int¶
The
event_dimparameter topyro.deterministic.
- __call__(self)¶
An
AbstractSampleris called whenStochasticencounters one as a “specification”, and it is this method that has to be overridden in subclasses to supply the desired value.
- class clipppy.stochastic.sampler.Effect(effect: Callable[[clipppy.utils._Tin], clipppy.utils._Tout], func_or_val: _ps_func_t, call: _ps_call_t = PseudoSampler.call)¶
The base class for “samplers”: objects that dynamically (or not) generate values in a
Stochasticcontext.- __call__(self) clipppy.utils._Tout¶
An
AbstractSampleris called whenStochasticencounters one as a “specification”, and it is this method that has to be overridden in subclasses to supply the desired value.
- class clipppy.stochastic.sampler.Factor¶
A
PseudoSamplerthat records the value as apyro.factor.- _func¶
- class clipppy.stochastic.sampler.NamedPseudoSampler¶
A
PseudoSamplerwith aname.Processes the value returned by
PseudoSampler.__call__through a function_functhat is given thenameas first argument and the value as second.- _func :ClassVar[Callable[[str, _ps_return_t], _ps_return_t]]¶
A function to process the value before returning.
It is called as
self._func(self.name, val, **kwargs). Subclasses can override this to e.g.pyro.deterministicandpyro.factor.
- __call__(self, **kwargs)¶
An
AbstractSampleris called whenStochasticencounters one as a “specification”, and it is this method that has to be overridden in subclasses to supply the desired value.
- class clipppy.stochastic.sampler.NamedSampler¶
A base class for samplers with a name.
These include
Sampler,Param,Deterministic, andFactorthat correspond to the respectivepyro.primitives.- _subclasses :ClassVar[set[Type[NamedSampler]]]¶
- name :str¶
The name of the sampler, used e.g. in
pyro.sampleandpyro.param.
- classmethod __init_subclass__(cls, **kwargs)¶
- class clipppy.stochastic.sampler.Param¶
Represents a
pyro.paramstatement.- event_dim :int¶
The
event_dimargument topyro.param.
- __call__(self)¶
Call
pyro.paramwith suitable arguments.- Returns
The result of the
paramstatement.- Return type
- class clipppy.stochastic.sampler.PseudoSampler¶
The base class for “samplers”: objects that dynamically (or not) generate values in a
Stochasticcontext.- call :_ps_call_t¶
- func_or_val :_ps_func_t¶
- __call__(self) _ps_return_t¶
An
AbstractSampleris called whenStochasticencounters one as a “specification”, and it is this method that has to be overridden in subclasses to supply the desired value.
- __repr__(self)¶
Return repr(self).
- class clipppy.stochastic.sampler.Sampler(d: _Sampler_dT, name: str = _Sampler.name, init: torch.Tensor = _Sampler.init, support: torch.distributions.constraints.Constraint = _Sampler.support, expand_by: Union[torch.Size, Iterable[int]] = _Sampler.expand_by, to_event: int = _Sampler.to_event, indep: Union[torch.Size, Iterable[int]] = _Sampler.indep, mask: torch.Tensor = _Sampler.mask, **kwargs)¶
Represents a
pyro.samplestatement.- d :_Sampler_dT¶
A( callable that returns a)*
distributionto be passed topyro.sample.
- infer :Mapping[str, Any]¶
- __call__(self)¶
An
AbstractSampleris called whenStochasticencounters one as a “specification”, and it is this method that has to be overridden in subclasses to supply the desired value.
- property distribution(self) pyro.distributions.torch_distribution.TorchDistributionMixin¶
The distribution from which to sample.
This is the result of repeatedly calling
self.Sampler.d(zero or more times) until adistributionpops out.
- class clipppy.stochastic.sampler.UnbindEffect(func_or_val: _ps_func_t, call: _ps_call_t = PseudoSampler.call, dim=- 1)¶
The base class for “samplers”: objects that dynamically (or not) generate values in a
Stochasticcontext.