Interpolation

Interpolation schemes between two data points in latent space.

ecgan.utils.interpolation.slerp(mu, low, high)[source]

Spherical linear interpolation based on White et al. 2016.

Originally introduced in Shoemake, 1985 and additional visualizations can be found in Huszár 2017 (Blogpost). Implementation adapted from ptrblack, GitHub and soumith, GitHub. Most probability mass in high-dimensional Gaussian latent spaces is in an annulus around the origin and points around the origin are scarce. To account for this, a meaningful interpolation should traverse the annulus and not travel through the center of the hypersphere.

Parameters
  • mu -- Parameter moving from 0 to 1 the closer it gets to high.

  • low -- Sample from latent space, origin of the interpolation process.

  • high -- Sample from latent space, target of the interpolation process.

Returns

Mu-based interpolated sample between low and high.

ecgan.utils.interpolation.spherical_interpolation(start, target, num_steps)[source]

Perform the interpolation between two points in a specified amount of steps.

Parameters
  • start -- One point (in latent space), of dimensionality (n,).

  • target -- Point which is approached during interpolation.

  • num_steps -- Amount of steps/samples taken during interpolation.

Returns

(num_steps x samples.shape).

Return type

Tensor

ecgan.utils.interpolation.latent_walk(base_sample, component, walk_range, device, latent_dims)[source]

Explore the latent space based on a single latent space sample.

Up to 10 dims are visualized.

Parameters
  • base_sample (Tensor) -- Initial latent sample of dim [1,1,latent_dim].

  • component (Module) -- The generative module that is used to create new samples.

  • walk_range (Tensor) -- The area of the latent sample investigated.

  • device (device) -- The device of the NN module.

  • latent_dims (Union[int, List]) -- Amount of dims walked through. If more dims exist than selected: Use the first n latent_dims. Only up to 10 latent_dims are allowed for this visualization.

Return type

Tensor

Returns

A tensor of reconstructed samples where each latent dim is altered in the direction of walk_range.