TimeGAN for Sequential Synthetic Data
TimeGAN combines an autoencoder's supervised step-by-step training with a GAN's adversarial realism check, so synthetic sequences get both correct temporal dynamics and plausible overall shape — something either technique alone tends to miss.
Prerequisites: The GAN Minimax Objective, Variational Autoencoders
A GAN trained directly on raw sequences learns to produce realistic-looking windows, but has no explicit pressure to get the step-to-step dynamics right — nothing directly checks whether plausibly follows from the way it does in real data, only whether a whole window looks real in aggregate. An autoencoder trained to predict the next step gets the dynamics right by construction, but on its own tends to produce blurry, averaged-out sequences because minimizing squared error rewards hedging between plausible futures rather than committing to one sharp, realistic one. TimeGAN's idea is to use both losses on the same shared latent space, so each fixes the other's blind spot.
The analogy: a coach and a judge working together
Training a sequence generator with only a step-prediction loss is like a coach who corrects your form one movement at a time but never watches the whole routine — you can nail every isolated step and still produce something that looks robotic overall. Training with only an adversarial loss is like a judge who only scores the finished routine's overall impression, never checking whether any individual movement was technically correct. TimeGAN puts both a coach and a judge on the same routine at once: a supervised step-by-step loss (the coach) enforces correct-moment-to-moment dynamics, and an adversarial loss (the judge) enforces that the whole sequence, viewed as one thing, is indistinguishable from a real one.
Four networks, one shared latent space
TimeGAN trains four networks jointly, all operating in a shared learned latent space rather than on raw data directly: an embedder mapping real sequences into , a recovery network mapping back out, a generator producing latent sequences from noise, and a discriminator telling real latent sequences from generated ones. The generator is trained with three losses added together:
In words: be realistic overall (adversarial), get each next latent step right given the real previous steps (supervised — the coach), and let the embedder/recovery pair reconstruct real data accurately (reconstruction, so the latent space stays a faithful, invertible representation rather than collapsing to something meaningless). The supervised loss specifically is:
In words: given the real latent state at , penalize the generator's prediction of the next latent state against the actual next real latent state — a direct, per-step accuracy check that a purely adversarial loss never provides.
Worked example 1: the supervised loss catching a dynamics error
Suppose real latent states at consecutive steps are , (a modest rise). The generator, conditioned on the real , predicts — wildly overshooting. Supervised loss for this step: , a large penalty applied immediately, per step, regardless of what the discriminator thinks of the sequence as a whole. A purely adversarial setup might not catch this error at all if the surrounding sequence still looks aggregately plausible.
Worked example 2: how the losses trade off
Say at some training checkpoint, adversarial loss is , supervised loss is , reconstruction loss is , with (typical TimeGAN weighting, since the latter two are on a smaller natural scale). Total: . If a later checkpoint improves adversarial realism to but supervised accuracy worsens to : total — worse overall despite the "judge" score improving, because the "coach" score got much worse and is weighted heavily. This is the mechanism that stops TimeGAN from trading away correct dynamics purely to look realistic in aggregate.
A mean-reverting path like this has an exact, checkable one-step rule (pull toward a long-run mean); TimeGAN's supervised loss is the same idea generalized to whatever step-to-step rule the real training data actually follows, learned rather than assumed.
TimeGAN trains a generator against both an adversarial loss (is the whole sequence realistic) and a supervised next-step loss computed in a shared learned latent space (is each step's dynamics correct given the real previous step) — fixing the blurriness of pure step-prediction models and the loose dynamics of pure GANs at once.
What this means in practice
TimeGAN-style models are used to generate synthetic multi-asset or multi-feature sequences — for example, joint price and volume paths, or panels of correlated factor returns — where getting the cross-sectional and temporal structure both right matters for downstream backtests, not just the marginal shape of any single series.
A model can post an excellent adversarial (discriminator-fooling) score while still getting basic dynamics wrong — for instance, generating returns that are individually plausible in isolation but whose one-step autocorrelation structure doesn't match real data at all. Always check the supervised/one-step-ahead accuracy separately from the adversarial realism score; a good overall "look" is not evidence of correct dynamics.
Related concepts
Practice in interviews
Further reading
- Yoon, Jarrett & van der Schaar, Time-series Generative Adversarial Networks (2019)