Coder Social home page Coder Social logo

qlan3 / quantumexplorer Goto Github PK

View Code? Open in Web Editor NEW
23.0 1.0 6.0 43 KB

A quantum reinforcement learning framework based on PyTorch and PennyLane.

License: MIT License

Python 99.67% Shell 0.33%
quantum-algorithms quantum-machine-learning quantum-reinforcement-learning pennylane variational-quantum-circuit quantum-neural-networks deep-reinforcement-learning gym pytorch reinforcement-learning soft-actor-critic

quantumexplorer's Introduction

Quantum Explorer

Quantum Explorer is a quantum reinforcement learning framework based on PyTorch and PennyLane.

Implemented algorithms

Requirements

Experiments

Train

All hyperparameters including parameters for grid search are stored in a configuration file in directory configs. To run an experiment, a configuration index is first used to generate a configuration dict corresponding to this specific configuration index. Then we run an experiment defined by this configuration dict. All results including log files and the model file are saved in directory logs. Please refer to the code for details.

For example, run the experiment with configuration file sac.json and configuration index 1:

python main.py --config_file ./configs/sac.json --config_idx 1

Grid Search (Optional)

First, we calculate the number of total combinations in a configuration file (e.g. sac.json):

python utils/sweeper.py

The output will be:

Number of total combinations in sac.json: 6

Then we run through all configuration indexes from 1 to 6. The simplest way is a bash script:

for index in {1..6}
do
  python main.py --config_file ./configs/sac.json --config_idx $index
done

Parallel is usually a better choice to schedule a large number of jobs:

parallel --eta --ungroup python main.py --config_file ./configs/sac.json --config_idx {1} ::: $(seq 1 6)

Any configuration index that has the same remainder (divided by the number of total combinations) should has the same configuration dict. So for multiple runs, we just need to add the number of total combinations to the configuration index. For example, 5 runs for configuration index 1:

for index in 1 7 13 19 25
do
  python main.py --config_file ./configs/sac.json --config_idx $index
done

Or a simpler way:

parallel --eta --ungroup python main.py --config_file ./configs/sac.json --config_idx {1} ::: $(seq 1 6 30)

Analysis (Optional)

To analyze the experimental results, just run:

python analysis.py

Inside analysis.py, analyze will generate a csv file in directory logs/sac/0 that store all training results. More functions are available in utils/plotter.py.

Enjoy!

Code of My Papers

  • Qingfeng Lan. Variational Quantum Soft Actor-Critic. arXiv preprint arXiv:2112.11921, 2021. [paper]

Cite

If you find this repo helpful to your research, you could cite my paper.

Acknowledgements

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.