Encoding Presets¶

class Preset[source]¶

Dummy parent (abstract) class of all encoder presets. An actual preset should inherit from this class.

Encoding preset defines how we encode each frame. They are similar to conventional codecs presets e.g x264 --slow preset offers better compression performance at the expense of a longer encoding.

Here a preset defines two things: how the warm-up is done, and how the subsequent training is done.

Parameters:
  • preset_name (str) – Name of the preset.

  • all_phases (List[TrainerPhase]) – The successive (post warm-up) training phase. Defaults to [].

  • warmup (Warmup) – The warm-up parameters. Defaults to Warmup().

pretty_string() str[source]¶

Return a pretty string describing a warm-up phase

Return type:

str

class TrainerPhase[source]¶

Dataclass representing one phase of an encoding preset.

Parameters:
  • lr (float) – Initial learning rate of the phase. Can vary if schedule_lr is True. Defaults to 0.01.

  • max_itr (int) – Maximum number of iterations for the phase. The actual number of iterations can be made smaller through the patience mechanism. Defaults to 10000.

  • freq_valid – Check (and print) the performance each frequency_validation iterations. This drives the patience mechanism. Defaults to 100.

  • patience – After patience iterations without any improvement to the results, exit the training. Patience is disabled by setting patience = max_iterations. If patience is used alongside cosine_scheduling_lr, then it does not end the training. Instead, we simply reload the best model so far once we reach the patience, and the training continue. Defaults to 1000.

  • quantize_model (bool) – If True, quantize the neural networks parameters at the end of the training phase. Defaults to False.

  • schedule_lr (bool) – If True, the learning rate is no longer constant. instead, it varies with a cosine scheduling, as suggested in C3: High-performance and low-complexity neural compression from a single image or video, Kim et al.. Defaults to False.

  • softround_temperature (Tuple[float, float]) – the softround function. It is used in the forward / backward if quantizer_type is set to "softround" or "softround_alone". It is also used in the backward pass if quantizer_type is set to "ste". The softround temperature is linearly scheduled during the training. At iteration n° 0 it is equal to softround_temperature[0] while at iteration n° max_itr it is equal to softround_temperature[1]. Note that the patience might interrupt the training before it reaches this last value. Defaults to (0.3, 0.3).

  • noise_parameter (Tuple[float, float]) – The random noise temperature is linearly scheduled during the training. At iteration n° 0 it is equal to noise_parameter[0] while at iteration n° max_itr it is equal to noise_parameter[1]. Note that the patience might interrupt the training before it reaches this last value. Defaults to (2.0, 1.0).

  • quantizer_noise_type (POSSIBLE_QUANTIZATION_NOISE_TYPE) – The random noise used by the quantizer. More information available in encoder/component/core/quantizer.py. Defaults to "kumaraswamy".

  • quantizer_type (POSSIBLE_QUANTIZER_TYPE) – What quantizer to use during training. See encoder/component/core/quantizer.py for more information. Defaults to "softround".

  • optimized_module (List[MODULE_TO_OPTIMIZE]) – List of modules to be optimized. Most often you’d want to use optimized_module = ['all']. Defaults to ['all'].

pretty_string() str[source]¶

Return a pretty string describing a warm-up phase

Return type:

str