Data Learning¶

class
torchelie.data_learning.
CorrelateColors
¶ Takes an learnable image and applies the inverse color decorrelation from ImageNet (ie, it correlates the color like ImageNet to ease optimization)

forward
(t)¶ Correlate the color of the image t and return the result

invert
(t)¶ Decorrelate the color of the image t and return the result


class
torchelie.data_learning.
ParameterizedImg
(*shape, init_sd=0.06, init_img=None, space='spectral', colors='uncorr')¶ A convenient wrapper around PixelImage and SpectralImage and CorrelateColors to make a learnable image.
Parameters:  *shape (int) – shape of the image: channel, height, width
 init_sd (float) – standard deviation for initializing the image if init_img is None
 init_img (tensor) – an image to use as initialization
 space (str) – either “pixel” or “spectral” to have the underlying representation be a PixelImage or a SpectralImage
 colors (str) – either “corr” or “uncorr”, to use a correlated or decorrelated color space

forward
()¶ Return the tensor

render
()¶ Return the tensor on cpu and detached, ready to be transformed to a PIL image

class
torchelie.data_learning.
PixelImage
(shape, sd=0.01, init_img=None)¶ A learnable image parameterized by its pixel values
Parameters:  shape (tuple of int) – a tuple like (channels, height, width)
 sd (float) – pixels are initialized with a random gaussian value of mean 0.5 and standard deviation sd
 init_img (tensor, optional) – an image tensor to initialize the pixel values

forward
()¶ Return the image

class
torchelie.data_learning.
SpectralImage
(shape, sd=0.01, decay_power=1, init_img=None)¶ A learnable image parameterized by its Fourier representation.
See https://distill.pub/2018/differentiableparameterizations/
Implementation ported from https://github.com/tensorflow/lucid/blob/master/lucid/optvis/param/spatial.py
Parameters:  shape (tuple of int) – a tuple like (channels, height, width)
 sd (float) – amplitudes are initialized with a random gaussian value of mean 0.5 and standard deviation sd
 init_img (tensor, optional) – an image tensor to initialize the image

forward
()¶ Return the image