CTGANGenerator<T>

Models & Types · AiDotNet.NeuralNetworks.SyntheticData

Conditional Tabular GAN (CTGAN) for generating realistic synthetic tabular data.

Inheritance: NeuralNetworkBase<T> → NeuralSyntheticTabularGeneratorBase<T> → CTGANGenerator<T>

Implements: ISyntheticTabularGenerator<T>

For Beginners

CTGAN works like a forgery competition:

  1. The Generator starts with random noise and tries to create realistic table rows
  2. The Discriminator sees both real and generated rows and tries to tell them apart
  3. They train together: the generator gets better at fooling the discriminator,

and the discriminator gets better at spotting fakes

  1. Eventually, the generator produces rows that are indistinguishable from real data

If you provide custom layers in the architecture, those will be used directly for the generator network. If not, the network creates industry-standard CTGAN layers based on the original research paper specifications.

Example usage:

How It Works

CTGAN combines several innovations for effective tabular data generation:

  • VGM normalization: Handles multi-modal continuous distributions
  • Conditional generation: Training-by-sampling ensures all categories are represented
  • WGAN-GP loss: Wasserstein distance with gradient penalty for stable training
  • Residual generator: Skip connections in the generator for better gradient flow
  • PacGAN: Packing multiple samples to prevent mode collapse

This implementation follows the standard neural network architecture pattern with:

  • Proper inheritance from NeuralNetworkBase
  • Layer-based architecture using ILayer components
  • Engine-based tensor operations for CPU/GPU acceleration
  • Full autodiff and JIT compilation support

Reference: “Modeling Tabular Data using Conditional GAN” (Xu et al., NeurIPS 2019)

Constructors

Constructor Summary
CTGANGenerator() Initializes a new CTGAN generator with the specified architecture.
CTGANGenerator(NeuralNetworkArchitecture<T> architecture, CTGANOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction)

Properties

Property Summary
CTGANOptions<T> Options { get; } Gets the CTGAN-specific options.
IReadOnlyList<ColumnMetadata> Columns { get; }
bool IsFitted { get; set; }

Methods

Method Summary
Dictionary<string, T> GetFeatureImportance()
Matrix<T> Generate(int numSamples, Vector<T> conditionColumn, Vector<T> conditionValue) Generates new synthetic tabular data rows.
ModelMetadata<T> GetModelMetadata()
Task FitAsync(Matrix<T> data, IReadOnlyList<ColumnMetadata> columns, int? epochs, CancellationToken ct)
void Fit(Matrix<T> data, IReadOnlyList<ColumnMetadata> columns, int? epochs) Fits the CTGAN generator to the provided real tabular data.