Skip to content

Commit

Permalink
Update detail.md
Browse files Browse the repository at this point in the history
change 'dHBV' to 'deltaModel' in code example + edits for clarity.
  • Loading branch information
leoglonz authored Dec 7, 2024
1 parent f490308 commit e9bc82f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/dmg/detail.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ LSTM to learn parameters for the [HBV](https://en.wikipedia.org/wiki/HBV_hydrolo
from example import load_config
from hydroDL2.models.hbv.hbv import HBV as hbv
from deltaModel.models.neural_networks import init_nn_model
from deltaModel.models.differentiable_model import DeltaModel as dHBV
from deltaModel.models.differentiable_model import DeltaModel
from deltaModel.core.data.data_loaders.hydro_loader import HydroDataLoader
from deltaModel.core.data.data_samplers.hydro_sampler import take_sample
Expand All @@ -222,7 +222,7 @@ nn = init_nn_model(phy_model, config['dpl_model'])
# 4. Create the differentiable model dHBV: a torch.nn.Module that describes how
# the NN is linked to the physical model HBV.
dpl_model = dHBV(phy_model=phy_model, nn_model=nn)
dpl_model = DeltaModel(phy_model=phy_model, nn_model=nn)
## From here, forward or train dpl_model just as any torch.nn.Module model.
Expand All @@ -231,15 +231,15 @@ dpl_model = dHBV(phy_model=phy_model, nn_model=nn)
output = dpl_model.forward(dataset_sample)
```

In the above, we illustrate a critical behavior of the differentiable model object `DeltaModel` (dHBV), which is the the composition of a physical model, `phy_model`, with a neural network, `nn`.
In the above, we illustrate a critical behavior of the differentiable model object `DeltaModel`, which is the the composition of the physical model, `phy_model=hbv`, with a neural network, `nn`.

When we forward DeltaModel, we feed scaled inputs for the NN (stored within the dataset dictionary) to the NN and forward, which then outputs a set of parameter predictions (the config and phy_model definition ensure NN output is of correct size). Then, these parameters pass with the dataset dictionary to the forward the phy_model and output final model predictions. Internally, these steps are represented within DeltaModel as
When we forward DeltaModel, we feed scaled inputs (stored within the dataset dictionary) to the NN and forward, which returns a set of predicted parameters. These parameters then pass with the dataset dictionary to forward the phy_model and output final model predictions. Internally, these steps are represented within DeltaModel forward method as

```python
# Parameterization
parameters = self.nn_model(dataset_sample['xc_nn_norm'])

# Physics model
# Physics model forward
predictions = self.phy_model(
dataset_sample,
parameters,
Expand Down

0 comments on commit e9bc82f

Please sign in to comment.