Add writing to zarr dataset for eval-mode of trained models #104
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe your changes
Adds new CLI flag to
neural_lam.train_model
called--save-eval-to-zarr-path <path-to-dataset>
which can be added when running neural-lam ineval
mode (i.e.neural_lan.train_model --eval ...
) to write the predictions to a zarr dataset stored in<path-to-dataset>
. This functionality is motivated by our want to be able to store model predictions for later verification.Example of usage:
Model trained with
$> pdm run python -m neural_lam.train_model --config_path tests/datastore_examples/mdp/danra_100m_winds/config.yaml --hidden_dim 2 --epochs 1 --ar_steps_train 3 --ar_steps_eval 3 --graph 1level
used for inference with
$> pdm run python -m neural_lam.train_model \ --config_path tests/datastore_examples/mdp/danra_100m_winds/config.yaml \ --hidden_dim 2 --epochs 1 --ar_steps_train 1 --ar_steps_eval 3 --eval val \ --load saved_models/train-graph_lam-4x2-01_24_17-2502/min_val_loss.ckpt \ --val_steps_to_log 3 --graph 1level --save-eval-to-zarr-path state_predictions.zarr/
results in:
NB: This does not implement the inversion of the transformations that take place in
mllam-data-prep
(e.g. splitting individual features back into separate variables and levels. Also, the zarr datasets store time as[start_time, elapsed_forecast_duration]
rather than[start_time, sample]
to avoid producing a large array with many empty-values (NaNs) which would otherwise happen because each sample has a different start time. In the snippet below I have demonstrated how one could return to absolute time (probably there is a better way to do this...):Example plot with time-axis showing elapsed time:
Example plot with time-axis showing absolute time:
This probably needs more work, but I think it is ready for people to try it out and let me know what they think 😄
Issue Link
Implements #89
Type of change
Checklist before requesting a review
pull
with--rebase
option if possible).Checklist for reviewers
Each PR comes with its own improvements and flaws. The reviewer should check the following:
Author checklist after completed review
reflecting type of change (add section where missing):
Checklist for assignee