Module code_gan

Module code_gan 

Source
Expand description

Generative Adversarial Network for Code Generation

Implements a GAN architecture for generating valid Rust AST candidates:

  • Generator: Maps latent vectors to Rust AST token sequences
  • Discriminator: Classifies code as real (valid) or fake (invalid)

§Architecture

Latent Vector z ─┬─► Generator ─► AST Tokens ─┬─► Discriminator ─► Valid/Invalid
                 │                            │
                 │   Real AST Samples ────────┘
                 │
                 └── (sampled from N(0, I))

§Example

use entrenar::generative::{CodeGan, CodeGanConfig};

let config = CodeGanConfig::default();
let mut gan = CodeGan::new(config);

// Training loop would alternate between generator and discriminator updates

Structs§

CodeGan
Complete Code GAN for generating Rust AST
CodeGanConfig
Configuration for the complete Code GAN
CodeGanStats
Statistics from GAN training
Discriminator
Discriminator network: classifies code as real or fake
DiscriminatorConfig
Configuration for the Discriminator network
Generator
Generator network: maps latent vectors to AST token sequences
GeneratorConfig
Configuration for the Generator network
LatentCode
Latent code representation (vector in latent space)
TrainingResult
Training result from a GAN update step

Functions§

sigmoid
Sigmoid activation function