bead.src.models package
Submodules
bead.src.models.flows module
Collection of flow strategies
- class bead.src.models.flows.CNN_Flow(dim, cnn_layers, kernel_size, test_mode=0, use_revert=True)[source]
Bases:
Module- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.flows.IAF(z_size, num_flows=2, num_hidden=0, h_size=50, forget_bias=1.0, conv2d=False)[source]
Bases:
Module- forward(z, h_context)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.flows.NSF_AR(dim=15, K=64, B=3, hidden_dim=8, base_network=<class 'bead.src.models.layers.FCNN'>)[source]
Bases:
ModuleNeural spline flow, auto-regressive. [Durkan et al. 2019]
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.flows.Planar[source]
Bases:
Module- forward(zk, u, w, b)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.flows.Sylvester(num_ortho_vecs)[source]
Bases:
ModuleSylvester normalizing flow.
- forward(zk, r1, r2, q_ortho, b, sum_ldj=True)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.flows.TriangularSylvester(z_size)[source]
Bases:
ModuleSylvester normalizing flow with Q=P or Q=I.
- forward(zk, r1, r2, q_ortho, b, sum_ldj=True)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
bead.src.models.layers module
- class bead.src.models.layers.CNN_Flow_Layer(dim, kernel_size, dilation, test_mode=0, rescale=True, skip=True)[source]
Bases:
Module- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.layers.Dilation_Block(dim, kernel_size, test_mode=0)[source]
Bases:
Module- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.layers.FCNN(in_dim, out_dim, hidden_dim)[source]
Bases:
ModuleSimple fully connected neural network.
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.layers.GraphConvolution(in_features, out_features, bias=True)[source]
Bases:
ModuleSimple GCN layer, similar to https://arxiv.org/abs/1609.02907
- forward(input, adj)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.layers.Identity[source]
Bases:
Module- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.layers.MaskedConv2d(in_features, out_features, size_kernel=(3, 3), diagonal_zeros=False, bias=True)[source]
Bases:
Module- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.layers.MaskedLinear(in_features, out_features, diagonal_zeros=False, bias=True)[source]
Bases:
Module- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
bead.src.models.models module
- class bead.src.models.models.AE(in_shape, z_dim, *args, **kwargs)[source]
Bases:
Module- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.models.AE_Dropout_BN(in_shape, z_dim, *args, **kwargs)[source]
Bases:
AE- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.models.ConvAE(in_shape, z_dim, *args, **kwargs)[source]
Bases:
Module- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.models.ConvFlow_ConvVAE(in_shape, z_dim, *args, **kwargs)[source]
Bases:
ConvVAEVariational auto-encoder with convolutional flows in the decoder.
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.models.ConvVAE(in_shape, z_dim, *args, **kwargs)[source]
Bases:
ConvAE- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.models.HouseholderSylvester_ConvVAE(in_shape, z_dim, *args, **kwargs)[source]
Bases:
ConvVAEVariational auto-encoder with householder sylvester flows in the decoder.
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.models.IAF_ConvVAE(in_shape, z_dim, *args, **kwargs)[source]
Bases:
ConvVAEVariational auto-encoder with inverse autoregressive flows in the decoder.
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.models.NSFAR_ConvVAE(in_shape, z_dim, *args, **kwargs)[source]
Bases:
ConvVAEVariational auto-encoder with auto-regressive neural spline flows in the decoder.
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.models.OrthogonalSylvester_ConvVAE(in_shape, z_dim, *args, **kwargs)[source]
Bases:
ConvVAEVariational auto-encoder with orthogonal flows in the decoder.
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.models.Planar_ConvVAE(in_shape, z_dim, *args, **kwargs)[source]
Bases:
ConvVAEVariational auto-encoder with planar flows in the decoder.
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class bead.src.models.models.TransformerAE(in_dim, h_dim=256, n_heads=1, latent_size=50, activation=<built-in function gelu>)[source]
Bases:
ModuleAutoencoder mixed with the Transformer Encoder layer
- Parameters:
nn (_type_) – _description_
- decoder(z: Tensor)[source]
_summary_
- Parameters:
z (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- class bead.src.models.models.TriangularSylvester_ConvVAE(in_shape, z_dim, *args, **kwargs)[source]
Bases:
ConvVAEVariational auto-encoder with triangular sylvester flows in the decoder.
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.