Shortcuts

Variational Callbacks

Useful callbacks for GANs, variational-autoencoders or anything with latent spaces.

Note

We rely on the community to keep these updated and working. If something doesn’t work, we’d really appreciate a contribution to fix!


Latent Dim Interpolator

Interpolates latent dims.

Example output:

Example latent space interpolation
class pl_bolts.callbacks.variational.LatentDimInterpolator(interpolate_epoch_interval=20, range_start=- 5, range_end=5, steps=11, num_samples=2, normalize=True)[source]

Bases: pytorch_lightning.callbacks.callback.Callback

Warning

The feature LatentDimInterpolator is currently marked under review. The compatibility with other Lightning projects is not guaranteed and API may change at any time. The API and functionality may change without warning in future releases. More details: https://lightning-bolts.readthedocs.io/en/latest/stability.html

Interpolates the latent space for a model by setting all dims to zero and stepping through the first two dims increasing one unit at a time.

Default interpolates between [-5, 5] (-5, -4, -3, …, 3, 4, 5)

Example:

from pl_bolts.callbacks import LatentDimInterpolator

Trainer(callbacks=[LatentDimInterpolator()])
Parameters
  • interpolate_epoch_interval (int) – default 20

  • range_start (int) – default -5

  • range_end (int) – default 5

  • steps (int) – number of step between start and end

  • num_samples (int) – default 2

  • normalize (bool) – default True (change image to (0, 1) range)

on_train_epoch_end(trainer, pl_module)[source]

Called when the train epoch ends.

To access all batch outputs at the end of the epoch, either:

  1. Implement training_epoch_end in the LightningModule and access outputs via the module OR

  2. Cache data across train batch hooks inside the callback implementation to post-process in this hook.

Return type

None

Read the Docs v: 0.6.0
Versions
latest
stable
0.6.0
0.5.0
0.4.0
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.1
docs-build-rtd
0.1.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.