src.encoders package

Subpackages

Submodules

src.encoders.base module

class src.encoders.base.BaseEncoder

Bases: ABC

abstract decode(image)
abstract encode(image)
abstract update(batch_of_images)

src.encoders.vae module

class src.encoders.vae.VAE(image_channels: int = 3, image_height: int = 42, image_width: int = 144, z_dim: int = 32, load_checkpoint_from: str = '')

Bases: BaseEncoder, Module

Input should be (bsz, C, H, W) where C=3, H=42, W=144

bottleneck(h)
decode(z)
distribution(x, device='cpu')
encode(x: ndarray, device='cpu') Tensor
forward(x)

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.

classmethod instantiate_from_config(config_file_location)

Initialize class from config file

Parameters

config_file_location (path) – Path to config file

Raises

ValueError – Error loading file

Returns

object from class.

Return type

cls

classmethod instantiate_from_config_dict(config)

Initialize class from config dictionary

Parameters

config (dictionary) – Create instance of class from dictionary.

Returns

Object from class and config.

Return type

cls

loss(actual, recon, mu, logvar, kld_weight=1.0)
reparameterize(mu, logvar)
representation(x)
schema = Map({Optional("image_channels"): Int(), Optional("image_height"): Int(), Optional("image_width"): Int(), Optional("z_dim"): Int(), Optional("load_checkpoint_from"): Str()})
training: bool
update(batch_of_images)

Module contents

Encoder definitions.