gt4sd.frameworks.granular.ml.models.no_encoding.core module

NoEncoding implementation.

Summary

Classes:

NoEncoding

NoEncoding module for adding inputs directly in the latent space.

Reference

class NoEncoding(name, position, data, latent_size=2, **kwargs)[source]

Bases: GranularEncoderDecoderModel

NoEncoding module for adding inputs directly in the latent space.

__init__(name, position, data, latent_size=2, **kwargs)[source]

Construct NoEncoding.

Parameters
  • name (str) – model name.

  • position (int) – position of the model.

  • data (Dict[str, str]) – data name mappings.

  • latent_size (int) – latent size. Defaults to 2.

decode(z, *args, **kwargs)[source]

Decode a latent space point.

Parameters

z (Any) – latent point.

Return type

Any

Returns

decoded sample.

encode(x, *args, **kwargs)[source]

Encode a sample.

Parameters

x (Any) – input sample.

Return type

Any

Returns

latent encoding.

inference(z, *args, **kwargs)[source]

Run the model in inference mode.

Parameters

z (Any) – sample.

Return type

Any

Returns

generated output.

forward(x, *args, **kwargs)[source]

Forward pass in the model.

Parameters

x (Any) – model input.

Return type

Any

Returns

model output.

_run_step(x, *args, **kwargs)[source]

Run a step in the model.

Parameters

x (Any) – model input.

Return type

Any

Returns

model step output.

encode_decode(x, *args, **kwargs)[source]

Encode and decode a sample.

Parameters

x (Any) – input sample.

Return type

Any

Returns

decoded sample.

step(input_data, target_data, device='cpu', current_epoch=0, *args, **kwargs)[source]

Training step for the model.

Parameters
  • input_data (Any) – input for the step.

  • target_data (Any) – target for the step.

  • device (str) – string representing the device to use. Defaults to “cpu”.

  • current_epoch (int) – current epoch. Defaults to 0.

Return type

Tuple[Any, Any, Any]

Returns

a tuple containing the step output, the loss and the logs for the module.

val_step(input_data, target_data, device='cpu', current_epoch=0, *args, **kwargs)[source]

Validation step for the model.

Parameters
  • input_data (Any) – input for the step.

  • target_data (Any) – target for the step.

  • device (str) – string representing the device to use. Defaults to “cpu”.

  • current_epoch (int) – current epoch. Defaults to 0.

Return type

Any

Returns

a tuple containing the step output, the loss and the logs for the module.

static add_model_specific_args(parent_parser, name, *args, **kwargs)[source]

Adding to a parser model specific arguments.

Parameters
  • parent_parser (ArgumentParser) – patent parser.

  • name (str) – model name.

Return type

ArgumentParser

Returns

update parser.

__annotations__ = {}
__doc__ = 'NoEncoding module for adding inputs directly in the latent space.'
__module__ = 'gt4sd.frameworks.granular.ml.models.no_encoding.core'