GithubHelp home page GithubHelp logo

sarodyatawatta / smart-calibration Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 5.45 MB

Deep reinforcement learning for smart calibration of radio telescopes. Automatic hyper-parameter tuning.

License: Apache License 2.0

Python 96.72% Shell 1.71% Jupyter Notebook 1.56%
reinforcement-learning elastic-net-regression hyperparameter-optimization radio-astronomy sagecal pytorch openai-gym ddpg td3 radio-telescopes

smart-calibration's Introduction

Smart Calibration

Using reinforcement learning for hyperparameter tuning in calibration of radio telescopes, and in other data processing pipelines (like elastic net regression). Code to accompany the paper Deep reinforcement learning for smart calibration of radio telescopes (preprint). Enhancements based on spatial regularization (preprint) are included.

RL agent code is based on this code. Prioritized experience replay memory code is based on this code.

Implemented in PyTorch, using openai.gym. Algorithms tested are: DDPG, TD3 and SAC. The figure below shows the performance of the three.

Performance of the algorithms learing the elastic net problem

Elastic net regression

Elastic net regression agent and environment

Run main_{ddpg|td3|sac}.py to use DDPG or TD3 or SAC. Prioritized experience replay can be enabled by using the flag prioritized=True. See also this for distributed learning.

Files included are:

autograd_tools.py: utilities to calculate Jacobian, inverse Hessian-vector product etc.

enetenv.py: openai.gym environment

enet_td3.py : TD3 agent

enet_ddpg.py: DDPG agent

enet_sac.py: SAC agent

enet_eval.py: evaluation and compare with sklearn GridSearchCV

lbfgsnew.py: LBFGS optimizer

main_ddpg.py: run this for DDPG

main_td3.py: run this for TD3

main_sac.py: run this for SAC

Calibration

Additional packages: python-casacore, astropy, openmpi

Simulation and Calibration software: SAGECal

Imaging software: Excon

Influence maps

Influence maps give a visual representation of the influence function of radio interferometric calibration. Here is a sample:

Influence maps

We use influence maps as part of the state representation. An analogy to this is visualizing an untrained and a trained CNN model. The figures below show the influence function for CIFAR10 classifier using AlexNet (untrained), AlexNet (trained) and ResNet18 (trained). With training, the figures become less random, but still has non-zero features implying overfitting in the training.

Alexnet untrained

Alexnet trained

ResNet18 trained

Note the difference between the trained AlexNet (65% accuracy) and ResNet18 (80% accuracy), the latter has much less bias.

Run main_{ddpg|td3|sac}.py to use DDPG or TD3 or SAC. You can copy some example data from here.

The figure below shows small areas in the sky before (left) and after (right) calibration.

Before and after calibration

Files included are:

calibration_tools.py: utility routines

simulate.py: generated sky models, systematic errors for data simulation

calibenv.py: openai.gym environment

analysis.py: calculate influence function/map

calib_td3.py: TD3 agent

calib_ddpg.py: DDPG agent

calib_sac.py: SAC agent

lbfgsnew.py: LBFGS optimizer

main_ddpg.py: run this for DDPG

main_td3.py: run this for TD3

main_sac.py: run this for SAC

docal.sh: shell wrapper to run calibration

doinfluence.sh: shell wrapper to run influence mapping

dosimul.sh : shell wrapper to run simulations

inspect_replaybuffer.py: inspect the replay buffer contents

The following scripts are for handling radio astronomical (MS) data

addcol.py: add new column to write data

changefreq.py: change observing frequency

readcorr.py: read data and output as text

writecorr.py: write text input and write to MS

addnoise.py : add AWGN to data

calmean.sh: calculate mean image

doall.sh: wrapper to do simulation, calibration, and influence map generation

smart-calibration's People

Contributors

sarodyatawatta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.