{"id":19103672,"url":"https://github.com/rkansal47/mpgan","last_synced_at":"2025-04-30T16:28:08.357Z","repository":{"id":39912192,"uuid":"382939833","full_name":"rkansal47/MPGAN","owner":"rkansal47","description":"The message passing GAN https://arxiv.org/abs/2106.11535 and generative adversarial particle transformer https://arxiv.org/abs/2211.10295 architectures for generating particle clouds ","archived":false,"fork":false,"pushed_at":"2025-04-07T17:05:53.000Z","size":165449,"stargazers_count":13,"open_issues_count":4,"forks_count":11,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T18:23:56.094Z","etag":null,"topics":["attention","deep-learning","generative-adversarial-network","graph-neural-networks","hep-ex","machine-learning","physics","pytorch","simulation","transformers"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rkansal47.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-04T20:10:39.000Z","updated_at":"2025-04-07T17:05:58.000Z","dependencies_parsed_at":"2023-01-27T23:15:17.614Z","dependency_job_id":"7aefa060-4fcd-4c8a-b957-d27ed2705f6d","html_url":"https://github.com/rkansal47/MPGAN","commit_stats":{"total_commits":226,"total_committers":4,"mean_commits":56.5,"dds":0.2566371681415929,"last_synced_commit":"f316f6837ff271fee29ef50c3cb8bce4dc1ca124"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkansal47%2FMPGAN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkansal47%2FMPGAN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkansal47%2FMPGAN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkansal47%2FMPGAN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rkansal47","download_url":"https://codeload.github.com/rkansal47/MPGAN/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251741746,"owners_count":21636316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["attention","deep-learning","generative-adversarial-network","graph-neural-networks","hep-ex","machine-learning","physics","pytorch","simulation","transformers"],"created_at":"2024-11-09T04:00:42.904Z","updated_at":"2025-04-30T16:28:07.924Z","avatar_url":"https://github.com/rkansal47.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MPGAN \u0026 GAPT\n\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/rkansal47/MPGAN/main.svg)](https://results.pre-commit.ci/latest/github/rkansal47/MPGAN/main)\n[![Codestyle](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![DOI](https://zenodo.org/badge/382939833.svg)](https://zenodo.org/badge/latestdoi/382939833)\n\nCode for models in:\n\n\n[1] Kansal et al., *Graph Generative Adversarial Networks for Sparse Data Generation in High Energy Physics*, [ML4PS @ NeurIPS 2020](https://ml4physicalsciences.github.io/2020/), [`2012.00173`](https://arxiv.org/abs/2012.00173). \\\n[2] Kansal et al., *Particle Cloud Generation with Message Passing Generative Adversarial Networks*, [NeurIPS 2021](https://proceedings.neurips.cc/paper/2021/hash/c8512d142a2d849725f31a9a7a361ab9-Abstract.html), [`2106.11535`](https://arxiv.org/abs/2106.11535). \\\n[3] Kansal et al., *Evaluating Generative Models in High Energy Physics*, [Phys. Rev. D **107** (2023) 076017](https://doi.org/10.1103/PhysRevD.107.076017), [`2211.10295`](https://arxiv.org/abs/2211.10295).\n\n\n## Overview\n\nThis repository contains PyTorch code for the message-passing GAN ([MPGAN](mpgan/model.py)) and generative adversarial particle transformer ([GAPT]((gapt/model.py))) models, as well as scripts for [training](train.py) the models from scratch, [generating](gen.py) and [plotting](plotting.py) the particle clouds. \nWe include also [weights](trained_models) of fully trained models discussed in [2]. \n\nAdditionally, we release the standalone [JetNet](https://github.com/jet-net/JetNet) library, which provides a PyTorch Dataset class for our JetNet dataset, implementations of the evaluation metrics discussed in the paper, and some more useful utilities for development in machine learning + jets.\n\n*For the exact code and scripts used for [2], please see the [neurips21](https://github.com/rkansal47/MPGAN/tree/neurips21) branch.*\n\n## Talks\n\nA complete list of talks can be found [here](https://www.raghavkansal.com/project/graph-gan/).\n\n## Dependencies\n\n#### MPGAN and GAPT Models\n\n - `torch \u003e= 1.8.0`\n\n#### Training, Plotting, Evaluation\n\n - `torch \u003e= 1.8.0`\n - `jetnet \u003e= 0.2.1`\n - `numpy \u003e= 1.21.0`\n - `matplotlib`\n - `mplhep`\n\n Can be installed via `pip install -r requirements.txt`.\n\n#### External models also require\n\n - `torch`\n - `torch_geometric`\n\n\nA Docker image containing all necessary libraries can be found [here](https://gitlab-registry.nautilus.optiputer.net/raghsthebest/mnist-graph-gan:nov22) ([Dockerfile](Dockerfile)).\n\n\n## Training\n\nStart training with:\n\n```python\npython train.py --name test_model --model [model] --jets [jets] [args]  \n```\n\nwhere `model` can be specified as `mpgan` or `gapt`, and jets can be any out of `['g', 't', 'q', 'w', 'z']`.\n\nBy default, model parameters, figures of particle and jet features, and plots of the training losses and evaluation metrics over time will be saved every five epochs in an automatically created `outputs/[name]` directory.\n\nSome notes:\n - Will run on a GPU by default if available. \n - The default arguments correspond to the final model architecture and training configuration used in the paper. \n - Run `python train.py --help` or look at [setup_training.py](setup_training.py) for a full list of arguments.\n - For protoyping purposes, models can also be trained on a 'sparsified' MNIST point cloud dataset as in [1] using `train_mnist.py`. Normal MNIST training and testing `.csv`s need to be downloaded and pointed to with the `--datasets-path` arg.\n\n\n## Generation\n\nPre-trained generators with saved state dictionaries and arguments can be used to generate samples with, for example:\n\n```python\npython gen.py --G-state-dict trained_models/mp_g/G_best_epoch.pt --G-args trained_models/mp_g/args.txt --num-samples 50,000 --output-file trained_models/mp_g/gen_jets.npy\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frkansal47%2Fmpgan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frkansal47%2Fmpgan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frkansal47%2Fmpgan/lists"}