ProgressiveGAN<T>

Models & Types · AiDotNet.NeuralNetworks

Progressive GAN (ProGAN, Karras et al. 2017) — a GAN that generates high-resolution images by progressively growing the generator and discriminator.

For Beginners: Progressive GAN trains a GAN to generate large images by starting small (4x4) and adding layers to grow the resolution. As in every GAN, the generator’s input is a 1D latent vector z; the original paper’s generator “applies a dense layer that projects the latent vector … followed by reshaping into a 4×4 spatial feature map before convolutions” (Karras et al. 2017), exactly the DCGAN/Goodfellow 2014 §3 latent→dense→reshape→conv-upsample pattern.

This implementation derives from GenerativeAdversarialNetwork, which supplies the proven tape-based adversarial training, and builds a paper-faithful 1D-latent generator and strided-conv discriminator (single logit + BCE-with-logits) sized to the target resolution (4·2^maxResolutionLevel). The progressive-growing schedule (per-resolution fade-in, minibatch-stddev, pixel-norm) is tracked as configuration; the network is built directly at the target resolution.

Based on “Progressive Growing of GANs for Improved Quality, Stability, and Variation” by Karras et al. (2018).

Inheritance: NeuralNetworkBase<T> → DeclaredModelLayoutBase<T> → ImageGeneratorModelLayoutBase<T> → GenerativeAdversarialNetwork<T> → ProgressiveGAN<T>

Example

var noise = Tensor<float>.CreateRandom(new[] { 1, 512 });
var trainX = Tensor<float>.CreateRandom(4, 8);
var trainY = Tensor<float>.CreateRandom(4, 2);
var result = new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
    .ConfigureModel(new ProgressiveGAN<float>(latentSize: 512, imageChannels: 3, options: new ProgressiveGANOptions { MaxResolutionLevel = 6 }))
    .Build(trainX, trainY);
var generated = result.Predict(noise);

Constructors

Constructor Summary
ProgressiveGAN(NeuralNetworkArchitecture<T> generatorArchitecture, NeuralNetworkArchitecture<T> discriminatorArchitecture, ProgressiveGANOptions options, ILossFunction<T> lossFunction) Backward-compatible constructor that accepts explicit generator/discriminator architectures.
ProgressiveGAN(int latentSize, int imageChannels, ProgressiveGANOptions options, ILossFunction<T> lossFunction) Backward-compatible constructor that accepts explicit generator/discriminator architectures.

Properties

Property Summary
T LastGradientPenalty { get; set; } Gets the last computed gradient penalty value (monitoring only).
bool UseMinibatchStdDev { get; set; } Gets or sets whether to use minibatch standard deviation.
bool UsePixelNormalization { get; set; } Gets or sets whether to use pixel normalization in the generator.
double Alpha { get; set; } Gets or sets the alpha value for smooth fade-in of new layers.
int CurrentResolutionLevel { get; set; } Gets the current resolution level (0 = 4x4, 1 = 8x8, 2 = 16x16, …).
int LatentSize { get; } Gets the size of the latent (noise) vector input to the generator.
int MaxResolutionLevel { get; } Gets the maximum resolution level the network can achieve.

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()
int GetCurrentResolution() Gets the current spatial resolution (4 · 2^CurrentResolutionLevel).