ConditionalVAE(encoder, decoder, hidden_size, latent_size, num_classes)¶
Conditional Variational Auto-Encoder (CVAE).
The difference with VAE is that CVAE uses labels information. For more details, refer to Learning Structured Output Representation using Deep Conditional Generative Models.
When encoder and decoder ard defined, the shape of the encoder’s output tensor and decoder’s input tensor must be \((N, hidden\_size)\). The latent_size must be less than or equal to the hidden_size.
input_x (Tensor) - The shape of input tensor is \((N, C, H, W)\), which is the same as the input of encoder.
input_y (Tensor) - The tensor of the target data, the shape is \((N,)\).
output (tuple) - (recon_x(Tensor), x(Tensor), mu(Tensor), std(Tensor)).
- Supported Platforms:
The input are x and y, so the WithLossCell method needs to be rewritten when using cvae interface.
generate_sample(sample_y, generate_nums, shape)¶
Randomly sample from the latent space to generate samples.
Tensor, the generated samples.