Contribute / Code map
Code map¶
This page shows where each step of the pipeline lives in the code, so that you can find the file to read or change.
The pipeline: the builder writes the catalogue, training writes a checkpoint, and evaluation and prediction read it.
Packages¶
Package |
What it does |
Start reading at |
|---|---|---|
Validates a configuration file |
||
Reads the catalogue, selects and splits stars, preprocesses spectra and labels, masks inputs and labels during training |
||
The networks and their output layers |
||
The loss and the predicted scatter |
||
The training loop, batches and checkpoints |
||
Loads checkpoints, predicts, evaluates, calibrates |
||
Saliency maps, anomaly detection, comparison of label sources |
||
Training and evaluation plots |
||
The |
|
Outside the package:
Path |
What it holds |
|---|---|
|
The catalogue builder |
|
The deprecated v1 pipeline |
|
Training configurations and saliency scripts |
|
The test suite; |
|
These docs (Build the docs) |
Training¶
dorothy train runs cmd_train in dorothy/cli/main.py, which calls these
functions in order.
complete_config_from_catalogue()fills in the settings that come from the catalogue, andExperimentConfigvalidates the result.load_training_data()selects the stars and loads them in one of three layouts (below).split()divides the rows into training, validation and test sets with the configured seed.fit()passes the data to theTrainer.fit*method of its layout. All of these methods share one training loop.save_checkpoint()andsave()write the checkpoint directory (File formats).
Layout |
Used for |
Storage |
|---|---|---|
|
One survey and one label source |
Dense arrays |
|
Several label sources with |
Dense arrays per survey and label source |
|
Every other configuration |
The training loop takes batches from
TensorBatchSource (dense arrays) or
SparseBatchSource (sparse storage). A
Batch holds a dict of spectra per
survey, a dict of has_data masks and a dict of labels per label source.
Evaluation and prediction¶
dorothy evaluate loads the checkpoint with
load_checkpoint(), reloads the data
with the same load_training_data, and scores the test rows with
evaluate_model(). That function
runs the model through forward_label_sources, as training validation does.
dorothy predict runs
predict_from_fits(): it reads the FITS
file with FITSLoader, preprocesses the
spectra and predicts with Predictor.
Where to make a change¶
To change |
Edit |
|---|---|
A configuration setting |
Its |
Which stars are used, or the split |
|
Spectrum or label preprocessing |
|
The network |
|
The loss |
|
The training loop |
|
The files of a checkpoint |
|
A command or its options |
|
The catalogue layout |
|
Several of these steps have one shared implementation; Shared definitions lists them. To add a survey, follow Add a survey.