DPCTGANGenerator<T>
Models & Types · AiDotNet.NeuralNetworks.SyntheticData
Differentially Private CTGAN (DP-CTGAN) for generating synthetic tabular data with formal (epsilon, delta)-differential privacy guarantees.
Inheritance: NeuralNetworkBase<T> → NeuralSyntheticTabularGeneratorBase<T> → DPCTGANGenerator<T>
Implements: ISyntheticTabularGenerator<T>
For Beginners
DP-CTGAN works exactly like CTGAN but with a “privacy shield”:
**Standard CTGAN training step:**DP-CTGAN training step:
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.
Example usage:
How It Works
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
DP-CTGAN modifies the CTGAN training loop to provide differential privacy:
- Per-sample gradient clipping: Each sample’s gradient is clipped to a fixed L2 norm
- Gaussian noise: Calibrated noise added to aggregated clipped gradients
- Privacy accounting: Tracks cumulative privacy cost using moments accountant
- Early stopping: Training halts when privacy budget is exhausted
Constructors
| Constructor | Summary |
|---|---|
DPCTGANGenerator() |
Initializes a new DP-CTGAN generator with the specified architecture. |
DPCTGANGenerator(NeuralNetworkArchitecture<T> architecture, DPCTGANOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) |
Properties
| Property | Summary |
|---|---|
DPCTGANOptions<T> Options { get; } |
Gets the DP-CTGAN-specific options. |
IReadOnlyList<ColumnMetadata> Columns { get; } |
|
bool IsFitted { get; set; } |
|
double CumulativeEpsilon { get; } |
Gets the cumulative privacy cost (epsilon) spent so far during training. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, T> GetFeatureImportance() |
|
Matrix<T> Generate(int numSamples, Vector<T> conditionColumn, Vector<T> conditionValue) |
|
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 DP-CTGAN generator to the provided real tabular data with differential privacy. |