std1.0.0-beta-7 SafeC docs

std :: ml::autoencoder

Struct std::ConvVae

#include <std/ml/autoencoder.h> source

struct ConvVae {
    struct ConvNet enc;
    struct Mlp muHead;
    struct Mlp logvarHead;
    struct ConvNet dec;
    struct VaeConfig cfg;
    struct Rng rng;
    float lastRecon;
    float lastKl;
}

Convolutional VAE: linear mu / log sigma^2 heads on the flattened encoder features, the loss of Vae. Reads latent, recon, beta, classes and seed from the config (hidden, hiddenLayers and act describe the nets you built and are ignored). classes > 0 makes it a conditional VAE: the label goes to the encoder as 'classes' extra input channels (one constant plane per class, see tensor_append_label_channels) and to the decoder as a one-hot appended to the code. So for C-channel images the encoder takes C + classes channels, the decoder latent + classes inputs and outputs C channels. 'y' holds the class indices, as for Vae.

Fields

§struct ConvNet encsource
§struct Mlp muHeadsource

features -> latent

§struct Mlp logvarHeadsource
§struct ConvNet decsource

latent (+ label) -> image

§struct Rng rngsource
§float lastReconsource
§float lastKlsource

Methods

§&FloatTensor encode(const &FloatTensor x, const &FloatTensor y)source · definition

mu

§&FloatTensor decode(const &FloatTensor z, const &FloatTensor y)source · definition
§&FloatTensor reconstruct(const &FloatTensor x, const &FloatTensor y)source · definition
§&FloatTensor sample(unsigned long n, ?&FloatTensor labels)source · definition

n samples from the prior; 'labels' (n class indices) for a conditional VAE, null otherwise.

§void collect_params(&Vec<&FloatTensor> out) constsource · definition

Parameterized (module.h).

§void collect_state(&Vec<&FloatTensor> out) constsource · definition
§void drop()source · definition
§void free() consumesource · definition

= drop()

§static struct ConvVae new(struct ConvNet enc, struct ConvNet dec, const &VaeConfig cfg)source · definition