STSGCN (Spatial-Temporal Synchronous Graph Convolutional Networks)

repository·master·Indexed 19 days ago

https://github.com/davidham3/stsgcn

A framework for spatial-temporal network data forecasting presented in AAAI 2020. The project provides a training pipeline via main.py, supporting Docker with NVIDIA and Microsoft OpenPAI deployments. It utilizes JSON configuration files to define model parameters, hyperparameters, and MXNet GPU contexts.

Tokens
863
Snippets
2
Records
5
Agent score
16%

What's inside STSGCN

  1. Set up STSGCN using Docker

    master

    The recommended way to run STSGCN is via Docker with NVIDIA support. Follow these steps to build the environment and run the training pipeline:

    1. Install Docker and nvidia-docker on your host machine.
    2. Build the Docker image from the docker directory:
      cd docker && docker build -t stsgcn/mxnet_1.41_cu100 .
    3. Download the dataset (e.g., STSGCN_data.tar.gz) and uncompress it:
      tar -zxvf data.tar.gz
    4. Configure GPU context: Open your specific configuration file (e.g., config/PEMS03/individual_GLU_mask_emb.json) and modify the ctx term to match your available GPU devices.
    5. Run the training using the Docker container, mounting your current directory to /mxnet inside the container:
      docker run -ti --rm --runtime=nvidia -v $PWD:/mxnet stsgcn/mxnet_1.41_cu100 python3 main.py --config config/PEMS03/individual_GLU_mask_emb.json
    cd docker && docker build -t stsgcn/mxnet_1.41_cu100 .
    
    tar -zxvf data.tar.gz
    
    docker run -ti --rm --runtime=nvidia -v $PWD:/mxnet stsgcn/mxnet_1.41_cu100 python3 main.py --config config/PEMS03/individual_GLU_mask_emb.json
  2. Input Data Shapes for STSGCN

    master

    The model expects data to be structured in specific dimensions for both input (data) and targets (label). The shapes are derived from the configuration file as follows:

    • Input (data): (batch_size, points_per_hour, num_of_vertices, 1)
    • Target (label): (batch_size, points_per_hour, num_of_vertices)

    Data is loaded using generate_data(graph_signal_matrix_filename), which yields training, validation, and testing sets.

  3. Configure STSGCN via JSON

    master

    The training process is driven by a JSON configuration file. Based on the implementation in main.py, the following keys are required or used:

    Required/Core Keys

    • batch_size: Integer size for training batches.
    • num_of_vertices: Number of nodes in the graph.
    • graph_signal_matrix_filename: Path to the graph signal matrix data.
    • epochs: Total number of training epochs.
    • learning_rate: Initial learning rate for the optimizer.
    • optimizer: Name of the optimizer to use (e.g., via MXNet).
    • points_per_hour: The temporal dimension size for the input data shapes.
    • max_update_factor: Factor used to calculate the max_update for the PolyScheduler.
    • num_for_predict: Number of steps used for evaluating test performance.

    Context and Hardware

    • ctx: Specifies the MXNet context. Can be an int (e.g., 0 for GPU 0) or a list of integers (e.g., [0, 1] for multiple GPUs).
  4. Run STSGCN training via CLI

    master

    The main.py script serves as the entrypoint for training the STSGCN model. It requires a JSON configuration file to define model parameters, data paths, and training hyperparameters. You can trigger training, testing, or visualization using command-line flags.

    CLI Arguments

    • --config <path>: Required. Path to the JSON configuration file.
    • --test: If provided, the program runs in test mode (limiting data to the first 100 samples) and sets the epoch count to 5.
    • --plot: If provided, renders the network graph as a graph.png file.
    • --save: If provided, saves the model checkpoint using the name STSGCN and the current epoch number.
    python main.py --config config.json --save --plot