# Welcome to astroNN’s documentation!¶

astroNN is a python package to do various kinds of neural networks with targeted application in astronomy by using Keras API as model and training prototyping, but at the same time take advantage of Tensorflow’s flexibility.

For non-astronomy applications, astroNN contains custom loss functions and layers which are compatible with Tensorflow. The custom loss functions mostly designed to deal with incomplete labels. astroNN contains demo for implementing Bayesian Neural Net with Dropout Variational Inference in which you can get reasonable uncertainty estimation and other neural nets.

For astronomy applications, astroNN contains some tools to deal with APOGEE, Gaia and LAMOST data. astroNN is mainly designed to apply neural nets on APOGEE spectra analysis and predicting luminosity from spectra using data from Gaia parallax with reasonable uncertainty from Bayesian Neural Net. Generally, astroNN can handle 2D and 2D colored images too. Currently astroNN is a python package being developed by the main author to facilitate his research project on deep learning application in stellar and galactic astronomy using SDSS APOGEE, Gaia and LAMOST data.

For learning purpose, astroNN includes a deep learning toy dataset for astronomer - Galaxy10 DECals Dataset.

## Indices, tables and astroNN structure¶

```
astroNN/
├── apogee/
│ ├── apogee_shared.py [shared codes across apogee module]
│ ├── chips.py [functions to deal with apogee detectors and spectra]
│ ├── downloader.py [functions to downlaod apogee data]
│ └── plotting.py [functions to plot apogee data]
├── data/
│ └── ... [multiple pre-compiled data in numpy format]
├── datasets/
│ ├── apogee_distances.py
│ ├── apogee_rc.py
│ ├── apokasc.py
│ ├── galaxy10.py [astroNN's galaxy10 related codes]
│ ├── h5.py
│ └── xmatch.py [coordinates cross matching]
├── gaia/
│ ├── downloader.py [functions to downlaod gaia data]
│ └── gaia_shared.py [function related to astrometry and magnitude]
├── lamost/
│ ├── chips.py [functions to deal with lamost detectors and spectra]
│ └── lamost_shared.py [shared codes across lamost module]
├── models/ [contains neural network models]
│ └── ... [NN models codes and modules]
├── nn/
│ ├── callbacks.py [Keras's callbacks]
│ ├── layers.py [Tensorflow layers]
│ ├── losses.py [Tensorflow losses]
│ ├── metrics.py [Tensorflow metrics]
│ └── numpy.py [handy numpy implementation of NN tools]
└── shared/ [shared codes across modules]
```

- Getting Started
- Contributor and Issue Reporting guide
- History
- Publications using astroNN
- Loss Functions and Metrics
- Correction Term for Magic Number
- Mean Squared Error
- Mean Absolute Error
- Mean Error
- Regression Loss and Predictive Variance Loss for Bayesian Neural Net
- Mean Squared Logarithmic Error
- Mean Absolute Percentage Error
- Mean Percentage Error
- Categorical Cross-Entropy
- Binary Cross-Entropy
- Categorical Cross-Entropy and Predictive Logits Variance for Bayesian Neural Net
- Binary Cross-Entropy and Predictive Logits Variance for Bayesian Neural Net
- Categorical Classification Accuracy
- Binary Classification Accuracy
- Zeros Loss

- Layers
- Monte Carlo Dropout Layer
- Monte Carlo Dropout with Continuous Relaxation Layer Wrapper
- Monte Carlo Spatial Dropout Layer
- Monte Carlo Gaussian Dropout Layer
- Monte Carlo Batch Normalization Layer
- Error Propagation Layer
- KL-Divergence Layer for Variational Autoencoder
- Polynomial Fitting Layer
- Mean and Variance Calculation Layer for Bayesian Neural Net
- Repeat Vector Layer for Bayesian Neural Net
- Fast Monte Carlo Integration Layer for Keras Model
- Gradient Stopping Layer
- Boolean Masking Layer
- TensorInput Layer

- Callbacks and Utilities
- NeuralODE
- Neural Nets Classes and Basic Usage
- Available astroNN Neural Net Classes
- NeuralNetMaster Class API
- Workflow of Setting up astroNN Neural Nets Instances and Training
- Load astroNN Generated Folders
- Load and Use Multiple astroNN Generated Folders
- Workflow of Testing and Distributing astroNN Models
- Creating Your Own Model with astroNN Neural Net Classes
- NeuralNetMaster Class

- Bayesian Neural Net with Dropout Variational Inference
- Gaia DR2 with astroNN result
- (25 Apr 2018 update) Neural Network Distance Prediction on the whole APOGEE DR14 result with Gaia DR2
- Plans/Questions
- Nerual Network Distance Prediction on the whole APOGEE DR14
- 2M16363993+3654060 Distance Disagreement between astroNN and Gaia/Anderson2017 Parallax
- Distance Prediction with APOGEE-North Spectra
- Distance Prediction with APOGEE-South Spectra
- Milkyway via the Eye of Neural Network

Uncertainty Analysis of Neural Nets with Variational Methods

Training neural net with DR14 APOGEE_Distances Value Added Catalogue using astroNN

- Mini Tools for APOGEE data
- Mini Tools for LAMOST data
- Mini Tools for Gaia data
- Compiling and Loading APOGEE and Gaia Datasets -
**astroNN.datasets** - APOGEE Spectra with Convolutional Neural Net -
**astroNN.models.ApogeeCNN** - APOGEE Spectra with Bayesian Neural Net -
**astroNN.models.ApogeeBCNN** - APOGEE Spectra with Censored Bayesian NN -
**astroNN.models.ApogeeBCNNCensored** - APOGEE Spectra with Bayesian NN and Gaia offset calibration -
**astroNN.models.ApogeeDR14GaiaDR2BCNN** - Convolutional Variational Autoencoder -
**astroNN.models.ApogeeCVAE** - StarNet (arXiv:1709.09182)
- Cifar10 with astroNN

## Acknowledging astroNN¶

**Deep learning of multi-element abundances from high-resolution spectroscopic data**[arXiv:1808.04428][ADS]

And here is a list of publications using `astroNN`

- Publications using astroNN