espnet3.systems.esp2_codec.src.models.gan_lightning_module.GANLightningModule
espnet3.systems.esp2_codec.src.models.gan_lightning_module.GANLightningModule
class espnet3.systems.esp2_codec.src.models.gan_lightning_module.GANLightningModule(model, config)
Bases: ESPnetLightningModule
Adapt AbsGANESPnetModel outputs to ESPnet3’s named optimizer path.
Initialize the module and disable Lightning’s automatic optimization.
GAN training alternates a generator turn and a discriminator turn within one batch, so Lightning’s automatic optimization is turned off and the two turns are stepped manually.
- Parameters:
- model – The GAN model to wrap, an
espnet2.train.abs_gan_espnet_model.AbsGANESPnetModel. - config – Resolved training config.
optimizers/schedulersdrive the named optimizer path, and the optionaltrainer.ganblock setsgenerator_first(default False) andskip_discriminator_prob(default 0.0).
- model – The GAN model to wrap, an
Examples
build_gan_trainer in espnet3/systems/esp2_codec/src/gan_trainer.py is the one place that instantiates this module: ESP2CodecSystem calls it for every AbsGANESPnetModel from the resolved training config.
```python from espnet3.systems.esp2_codec.src.gan_trainer import build_gan_trainer from espnet3.utils.task_utils import get_espnet_model
model = get_espnet_model(config.task, config.model) trainer = build_gan_trainer(config, model) # wraps the model here assert trainer.model.automatic_optimization is False trainer.fit() `` The module can also be built directly, for a test or a custom trainer:
module = GANLightningModule(model, config)
``