-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
As an example, we want to show if the partitioning module can be replaced with an nn.module, e.g. partitioning_states = partitioning_nn(dvs).
Requirements:
- Add the new class
PartitioningNNin a directoryml_models/crop/partitioning.py, use simplenn.modulesuch asnn.ReLU(), implement partitioning conditions (positive and sum to 1), see this pcse notebook / 11 Optimizing partitioning in a PCSE model.ipynb for physical conditions. - Use wofost72_pp as base, plug the
PartitioningNNin either existing partitioning module or the wofost72 module; depends on the implementation and kiosk, see also the example code block below: - Add docs and a notebook showing end to end hybrid modeling (with training the model)
- See other requirements in [Backlog Item]: Build hybrid modeling framework #11
- See related notebook [Task] Check if parameters of
Partioningshould be optimizable #73
import torch.nn as nn
class PartitioningNN(nn.Module):
def __init__(self, ...):
...
def forward(self, dvs):
return partition_states/rates
class HybridModel(nn.Module):
def __init__(self, physical_params):
super().__init__()
self.partitioning_nn = PartitioningNN(input_size=3)
# pass self.partitioning_nn to wofost via config or another implementation
wofost72_config = Configuration(
CROP=Wofost72,
SOIL=WaterbalancePP,
ML=self.partitioning_nn, # this can be more generic later
OUTPUT_VARS=...,
)
self.engine = Engine(..., config=wofost72_config)
self.physical_params = nn.ParameterDict(...)
def forward(self, ...):
model = self.engine.setup(...)
model.run_till_terminate()
results = model.get_output()
return resultsReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
To Do