Two Stage Gan In Trajectory Generation

A Two-Stage Gan architecture to generate trajectory conditioned on maps information.
Alternatives To Two Stage Gan In Trajectory Generation
Select To Compare


Large Scale GPS Trajectory Generation Using Map based on Two-stage-GAN

Python impletement of paper Large Scale GPS Trajectory Generation Using Map based on Two-stage-GAN (Link)


we propose a map-based Two-Stage GAN method (TSG) to generate fine-grained and plausible large-scale trajectories. In the first stage, we first transfer GPS points data to discrete grid representation as the input for a modified deep convolutional generative adversarial network to learn the general pattern. In the second stage, inside each grid, we design an effective encoder-decoder network as the generator to extract road information from map image and then embed it into two parallel Long Short-Term Memory networks to generate GPS point sequence.


We evaluate the synthetic trajectories in terms of their similarity to real data, i.e., distribution of overall GPS coordinate, distribution of trajectory sequences length, distribution of trajectory distance, top-N visited places and road networks matching accuracy. And we compare our result with the previous benchmark.

JS distance of distribution

Model $p_o(r)$ $p_s(l)$ $p_d(l)$
FTS-IP 0.413 0.182 0.187
LSTM 0.633 0.058 0.140
TSG 0.100 0.139 0.136

Visualization of road network matching



Trajectory data in Porto, available on Kaggle

Prepare the data

  1. Transform trajectory data into grids format pre_process/process_trajectory_data/

  2. Prepare the corresponding map images:

    • go to pre_process/map_generation/

    • run

    • run

    • run

First stage GAN

  1. go to First_stage_gan/.

  2. run:

python \
--dataroot ./grid32/ \
--labelroot ./traj_all_0115.txt \
--outf ./output \
--batchSize 64 \
--n_critic 1 \
--netG ./output_IN/netG_epoch_320.pth \
--netD ./output_IN/netD_epoch_320.pth \
--cuda \
--start_iter 320 \
--niter 350

Second stage GAN

  1. go to Second_stage_gan.

  2. run python

Generate trajectory data

  1. Coarse result generated from First stage GAN
cd First_stage_gan
python --large_num 200 --model_path ./output_IN/netG_epoch_260.pth --output_path ../output_generated_coarse
  1. Final result TSG/


    • step_1_output path to the result of first stage GAN
    • map_dir path to the map data
    • checkpoint model result of second stage GAN


    author = {Xingrui Wang and Xinyu Liu and Ziteng Lu and Hanfang Yang},
    title = {Large Scale GPS Trajectory Generation Using Map Based on Two Stage GAN},
    journal = {Journal of Data Science},
    volume = {19},
    number = {1},
    year = {2021},
    pages = {126-141},
    doi = {10.6339/21-JDS1004},
    issn = {1680-743X},
    publisher = {School of Statistics, Renmin University of China}
Popular Machine Learning Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Generative Adversarial Network