Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a release for paper #72

Merged
merged 28 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ Code repository and documentation for:
![](sections/overview/str.png) ![](https://www.unsw.edu.au/content/dam/images/graphics/logos/unsw/unsw_0.png)

- [STR](https://www.str.us)
- [University of New South Wales, Sydney](https://www.ccrc.unsw.edu.au/ccrc-team/academic-research/steven-sherwood)
- Jim Gimlett
- Gregory Bushey
- Kirill Trapeznikov
- Eric Jones
- [University of New South Wales, Sydney](https://www.unsw.edu.au/)
- [Steven Sherwood](https://www.unsw.edu.au/staff/steven-sherwood)
- [Abhnil Prasad](https://www.unsw.edu.au/staff/abhnil-prasad)
- David Fuchs

## Sections
- [Datasets](sections/datasets/README.md) - description of datasets used in surrogate training
Expand All @@ -29,7 +36,9 @@ Code repository and documentation for:
- [MJO Analysis](sections/mjo_analysis/README.md) - analysis of MJO in the datasets
- [Surrogate Bottleneck Analysis](sections/bottleneck/README.md) - analysis of bottleneck dimension of the surrogate model
- [Linearization](sections/linearization/README.md) - analysis linearization of surrogate models to understand sensitivity to inputs

- [Surrogate Architectures](sections/architectures/README.md) - comparison of different neural network architectures and configurations
- [Fine Tuning](sections/finetuning/README.md) - comparison of fine-tuning an CAM4 trained model on SPCAM vs a model traiend from scratch
- [Integration Journal](sections/integration/README.md) - details on integration including training setup, diagnostic plots, etc.

## Overview

Expand Down
Binary file modified docs/milestone_reports/milestone_report_5.pdf
Binary file not shown.
Binary file not shown.
Binary file modified docs/milestone_reports/milestone_report_6.pdf
Binary file not shown.
17 changes: 17 additions & 0 deletions docs/sections/architectures/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Comparison of Different Surrogate Neural Network Architectures

We compare skill of trained surrogates with different architectures. The models are designed to have approx. same number of parameters: `1.5 millions`.

There are two variations:

| Architecture | Description |
| -- | -- |
| **Non-spatial** | *models treat each grid column independently* |
| fcn | fully connected network, 7 dense layers |
| conv1d_k | 1 dimensional conv net with dialation, z / levels = sequence dimension, variables = channel dimension, k = kernel size |
| transformer | transformer encoder model with z / level position encoding, z / levels = sequence dimension, variables = channel dimension |
| **Spatial** | *models can use information from neighbouring grids in making predictions* |
| *conv2d_k* | 2 dimensional seperable depthwise conv net, lat/lots = 2d spatial dimensions, variables stacked as channels, k = kernel size |


[![](skill_vs_nn_arch.png)](skill_vs_nn_arch.html)
73 changes: 73 additions & 0 deletions docs/sections/architectures/skill_vs_nn_arch.html

Large diffs are not rendered by default.

Binary file added docs/sections/architectures/skill_vs_nn_arch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions docs/sections/finetuning/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Finetuning Experiments

Our strategy is to iteravly refine neural networks surrogates by training on them on progessively higher fidelity physics simulation data.

To test our our fine-tuning strategy, we fine-tune a CAM4 trained NN surrogate on an increasing amount of SPCAM data. We compare fine-tuned model to a regular model trained from SCRATCH on the SPCAM data using the same amount data.

The following plot shows the benefit of fine-tuning vs training from scratch.

![](spcam-funetune.png)

Training paramaters:
- Total number of samples, N = 18e6, (in SPCAM training data)
- Subsample factor, S = 2 ^ [3, 4, …. , 17]
- For all, max_epochs: 200 / log(S)
- For all, batch_size = min( 24 x 96 x 144, N / S)
- Fine-tune: learning rate 5e-5, no learning rate schedule
- Train from scratch/random init: learning rage 1e-3, warm up schedule (ramp from 0 to lr during first 10% of epochs and then ramp down from lr to 0 during last 90%)
- Best model over epochs taken w.r.t. to validation set
Binary file added docs/sections/finetuning/spcam-funetune.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
854 changes: 854 additions & 0 deletions docs/sections/integration/README.md

Large diffs are not rendered by default.

51 changes: 47 additions & 4 deletions docs/sections/linearization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,55 @@

We compute linearization of the NN surrigate f(x) = y, to understand sensitivity to different inputs.

Linearization of f(x`) = Ax` + b, can be computed by computing the gradiant grad f(x) around x`. Since f(x) is vector valued we compute a jacobian: A = J_x(f(x)).
Linearization of $f(x) = Ax + b$, can be computed by taking the gradiant $grad~f(x)$ around $x$. Since f(x) is vector valued we compute a jacobian instead: $A = J_x(f(x))$.

To visualize how much each input perturbs every output, we l2 normalize each row of J. The following figure breaks up J by different output and input groups. This is computed around the mean input.

## CAM4



## Jacobian of Temperature and Humidity Tendencies

- We can compare empirical Jacobian of surrogate NN with reference CRM computations.
- While the general structure is present in the surrogate, it still somewhat noisy.
- We plan to add Jacobian structure as an additional regularization during optimization to (hopefully) encourage stability during intergration into the climate model.
> To compute the Jacobian, we sample 10000 data inputs from desired region, compute a jacobian around each sample using NN autodifferentiation and then average. We found that this computation is more stable then computing Jacobian around a mean input.

### Comparison to Reference CRM

[*Click on figure for interactive visualization*](jacobian_proper_scale.html)

Jacobian CAM4 FCN NN | Reference from CRM (Fig 8. Kuang 2012)
:-------------------------: | :-------------------------:
[![](jacobian_proper_scale.png)](jacobian_proper_scale.html) | [![](ref_jacobian.png)](ref_jacobian.png)


Jacobian SPCAM FCN NN | Reference from CRM (Fig 8. Kuang 2012)
:-------------------------: | :-------------------------:
[![](jacobian_proper_scale_spcam.png)](jacobian_proper_scale_spcam.html) | [![](ref_jacobian.png)](ref_jacobian.png)

<!-- [*By different lats*](jacobian_norm_cam4_by_lats.html) -->


<!-- ### l2 Normalized Jacobian of All Inputs

To visualize how much each input perturbs every output, we l2 normalize each row of J. The following figure breaks up J by different output and input groups. This is computed around the mean input.

[*Click on figure for interactive visualization*](jacobian.html)
[![](jacobian.png)](jacobian.html) -->


### Architecture Comparison

Jacobian CAM4 NN

[![](jacobian_compare_cam4.png)](jacobian_compare_cam4.html)

Jacobian SPCAM NN


[![](jacobian_compare_spcam.png)](jacobian_compare_spcam.html)


### Bottleneck

[![](jacobian.png)](jacobian.html)
[![](jacobian_bottleneck_cam4.png)](jacobian_bottleneck_cam4.html)
73 changes: 73 additions & 0 deletions docs/sections/linearization/jacobian_bottleneck_cam4.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions docs/sections/linearization/jacobian_compare_cam4.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions docs/sections/linearization/jacobian_compare_spcam.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions docs/sections/linearization/jacobian_proper_scale.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions docs/sections/linearization/jacobian_proper_scale_spcam.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/sections/linearization/ref_jacobian.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/talks/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@