BigGAN<T>

Models & Types · AiDotNet.NeuralNetworks

BigGAN (Brock et al. 2018) — a large-scale GAN for high-fidelity image generation.

For Beginners: BigGAN scales up GAN training (very large batches, high model capacity, class conditioning) to produce extremely high-quality images. As in every GAN, the generator’s input is a 1D latent noise vector z, which a first dense layer projects and reshapes into a small spatial feature map before transposed convolutions upsample it to a full image (Brock et al. 2018: “the first linear layer projects z … then reshapes into a spatial feature map”; Goodfellow 2014 §3).

This implementation derives from GenerativeAdversarialNetwork, which supplies the proven tape-based adversarial training, and builds a paper-faithful DCGAN-style backbone (1D-latent generator, strided-conv discriminator with a single logit + BCE-with-logits). Class-conditional batch normalization / the projection discriminator are tracked as metadata (NumClasses / ClassEmbeddingDim) rather than wired into the unconditional base training loop.

Based on “Large Scale GAN Training for High Fidelity Natural Image Synthesis” by Brock et al. (2019).

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

Example

var noise = Tensor<float>.CreateRandom(new[] { 1, 120 });
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 BigGAN<float>(
        latentSize: 128, numClasses: 10, classEmbeddingDim: 128,
        imageChannels: 3, imageHeight: 64, imageWidth: 64))
    .Build(trainX, trainY);
var generated = result.Predict(noise);

Constructors

Constructor Summary
BigGAN(NeuralNetworkArchitecture<T> generatorArchitecture, NeuralNetworkArchitecture<T> discriminatorArchitecture, BigGANOptions options, ILossFunction<T> lossFunction) Backward-compatible constructor that accepts explicit generator/discriminator architectures.
BigGAN(int latentSize, int numClasses, int classEmbeddingDim, int imageChannels, int imageHeight, int imageWidth, BigGANOptions options, ILossFunction<T> lossFunction) Initializes a BigGAN with paper-faithful architectures built from the image dimensions and latent size.

Properties

Property Summary
bool UseSelfAttention { get; set; } Gets or sets whether self-attention is used.
bool UseSpectralNormalization { get; set; } Gets or sets whether spectral normalization is used.
bool UseTruncation { get; set; } Gets or sets whether the truncation trick is applied at generation time.
double TruncationThreshold { get; set; } Gets or sets the truncation threshold for the truncation trick.
int ClassEmbeddingDim { get; } Gets the dimensionality of the class embedding.
int LatentSize { get; } Gets the size of the latent (noise) vector input to the generator.
int NumClasses { get; } Gets the number of classes for conditional generation.

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()