GithubHelp home page GithubHelp logo

natalidesanti / cosmographnet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pablovd/cosmographnet

0.0 1.0 0.0 3.88 MB

Graph Neural Networks to predict the cosmological parameters or the galaxy power spectrum from galaxy catalogs.

License: MIT License

Python 100.00%

cosmographnet's Introduction

CosmoGraphNet

DOI arXiv

Graph Neural Networks to predict the cosmological parameters and the galaxy power spectrum from galaxy catalogues.

A graph is created from a galaxy catalogue with information about the 3D position and intrinsic galactic properties. A Graph Neural Network is then applied to infer the cosmological parameters or the galaxy power spectrum. Galaxy catalogues extracted from the CAMELS hydrodynamic simulations, specially suited for Machine Learning purposes. Neural nets architectures are defined making use of the package PyTorch-geometric.

See the paper arXiv:2204.13713 for more details.

Description of the codes

Here is a brief oveview of the codes included:

  • main.py: main driver to train and test the network.

  • hyperparameters.py: script with the definition of the hyperparameters employed by the networks.

  • crosstest.py: tests a pre-trained model.

  • hyperparams_optimization.py: optimize the hyperparameters using optuna.

  • ps_test.py: tests the power spectrum neural networks in point distributions with different clustering properties.

  • visualize_graphs.py: display graphs from galaxy catalogues in 2D or 3D.

The folder Source contains scripts with auxiliary routines:

  • constants.py: basic constants and initialization.

  • load_data.py: contains routines to load data from simulation files.

  • plotting.py: includes functions for displaying the results from the neural nets.

  • metalayer.py: includes the definition of the Graph Neural Networks architecture.

  • training.py: includes routines for training and testing the net.

Requisites

The libraries required for training the models and compute some statistics are:

  • numpy
  • pytorch
  • pytorch-geometric
  • matplotlib
  • scipy
  • sklearn
  • optuna (only for optimization in hyperparams_optimization.py)
  • Pylians (only for computing power spectra in ps_test.py)

Usage

The codes implemented here are designed to train Graph Neural Network for two tasks. The desired task is chosen in hyperparameters.py with the outmode flag:

  1. Infer cosmological parameters from galaxy catalogues. Set outmode = "cosmo".
  2. Predict the power spectrum from galaxy catalogues. Set outmode = "ps".

These are some advices to employ the scripts described above:

  1. To perform a search of the optimal hyperparameters, run hyperparams_optimization.py.
  2. To train a model with a given set of parameters defined in hyperparameters.py, run main.py. The hyperparameters currently present in hyperparameters.py correspond to the best optimal values for each suite when all galactic features are employed (see the paper). Modify it accordingly to the task.
  3. Once a model is trained to perform cosmological parameter inference, run crosstest.py to test in the training simulation suite and cross test it in the other one included in CAMELS (IllustrisTNG and SIMBA). It needs a pretrained model.
  4. If a model has been trained to predict the power spectrum from CAMELS galaxy catalogues, evaluate its extrapolation performance on different point distributions running ps_test.py. It needs a pretrained model.

Citation

If you use the code, please link this repository, and cite arXiv:2204.13713 and the DOI 10.5281/zenodo.6485804.

Contact

Feel free to contact me at [email protected] for comments, questions and suggestions.

cosmographnet's People

Contributors

pablovd avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.