nami.lazy#

Classes

LazyDistribution(*args, **kwargs)

LazyField(*args, **kwargs)

UnconditionalDistribution(dist)

UnconditionalField(field)

class nami.lazy.LazyDistribution(*args, **kwargs)[source]#

Bases: Module

Parameters:
forward(c=None)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Return type:

Distribution

Parameters:

c (Tensor | None)

class nami.lazy.LazyField(*args, **kwargs)[source]#

Bases: Module

Parameters:
property event_ndim: int | None#
forward(c=None)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:

c (Tensor | None)

class nami.lazy.UnconditionalDistribution(dist)[source]#

Bases: LazyDistribution

Parameters:

dist (torch.distributions.Distribution)

forward(c=None)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Return type:

Distribution

Parameters:

c (Tensor | None)

class nami.lazy.UnconditionalField(field)[source]#

Bases: LazyField

Parameters:

field (nn.Module)

property event_ndim: int | None#
forward(c=None)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:

c (Tensor | None)