Normalizing Flow Module

class maf.BatchNorm(input_size, momentum=0.9, eps=1e-05)[source]

Bases: Module

RealNVP BatchNorm layer

forward(x, cond_y=None)[source]

Defines 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.

inverse(y, cond_y=None)[source]
training: bool
class maf.FlowSequential(*args: Module)[source]
class maf.FlowSequential(arg: OrderedDict[str, Module])

Bases: Sequential

Container for layers of a normalizing flow

forward(x, y)[source]

Defines 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.

inverse(u, y)[source]
class maf.LinearMaskedCoupling(input_size, hidden_size, n_hidden, mask, cond_label_size=None)[source]

Bases: Module

Modified RealNVP Coupling Layers per the MAF paper

forward(x, y=None)[source]

Defines 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.

inverse(u, y=None)[source]
training: bool
class maf.MADE(input_size, hidden_size, n_hidden, cond_label_size=None, activation='relu', input_order='sequential', input_degrees=None)[source]

Bases: Module

property base_dist
forward(x, y=None)[source]

Defines 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.

inverse(u, y=None, sum_log_abs_det_jacobians=None)[source]
log_prob(x, y=None)[source]
training: bool
class maf.MAF(n_blocks, input_size, hidden_size, n_hidden, cond_label_size=None, activation='relu', input_order='sequential', batch_norm=True)[source]

Bases: Module

property base_dist
forward(x, y=None)[source]

Defines 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.

inverse(u, y=None)[source]
log_prob(x, y=None)[source]
training: bool
class maf.MaskedLinear(input_size, n_outputs, mask, cond_label_size=None)[source]

Bases: Linear

MADE building block layer

extra_repr()[source]

Set the extra representation of the module

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

forward(x, y=None)[source]

Defines 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.

in_features: int
out_features: int
weight: Tensor
class maf.RealNVP(n_blocks, input_size, hidden_size, n_hidden, cond_label_size=None, batch_norm=True)[source]

Bases: Module

property base_dist
forward(x, y=None)[source]

Defines 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.

inverse(u, y=None)[source]
log_prob(x, y=None)[source]
training: bool
maf.create_masks(input_size, hidden_size, n_hidden, input_order='sequential', input_degrees=None)[source]