DCGAN<T>

Models & Types · AiDotNet.NeuralNetworks

Represents a Deep Convolutional Generative Adversarial Network (DCGAN), an architecture that uses convolutional and transposed convolutional layers with specific design guidelines for stable training.

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

For Beginners

DCGAN is an improved version of the basic GAN that uses specific design patterns to make training more stable and produce higher quality images.

Key improvements over vanilla GAN:

  • Uses convolutional layers specifically designed for images
  • Includes batch normalization to stabilize training
  • Follows proven architectural guidelines
  • Produces sharper, more realistic images

Reference: Radford et al., “Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks” (2015)

How It Works

DCGAN introduces several architectural constraints that improve training stability:

  • Replace pooling layers with strided convolutions (discriminator) and fractional-strided

convolutions/transposed convolutions (generator)

  • Use batch normalization in both generator and discriminator
  • Remove fully connected hidden layers for deeper architectures
  • Use ReLU activation in generator for all layers except output (uses Tanh)
  • Use LeakyReLU activation in discriminator for all layers

Example

var architecture = new NeuralNetworkArchitecture<float>(inputFeatures: 8, outputSize: 4);
var noise = Tensor<float>.CreateRandom(new[] { 1, 100 });
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 DCGAN<float>(architecture))
    .Build(trainX, trainY);
var generated = result.Predict(noise);

Constructors

Constructor Summary
DCGAN(NeuralNetworkArchitecture<T> architecture, DCGANOptions options) Creates a DCGAN with default dimensions derived from the architecture.
DCGAN(int latentSize, int imageChannels, int imageHeight, int imageWidth, DCGANOptions options, ILossFunction<T> lossFunction) Initializes a new instance of the DCGAN class with default DCGAN architecture.