Currently, the file wgan-gp
is a bit crazy. Specifically SuperResolutionWGANGP
-- our PyTorch Lightning class. Throughout the code, there is a complex nested heirarchy that comes from the hydra config dictionary which is not ideal. I propoe that we use a heirarchical structure based on dataclasses and inheritance to separate out some of this configuration information to make the code a bit cleaner and bit more explicit in how to access certain data related to training. Ultimately, my hope is that it will lead to more configurable code for scientific experimentation where we track changes to configurations rather than changes to the underlying code.
One way of helping reduce the number of lines of code, and factor out the config in a more logicla sense is to use hydra's instantiate feature, where you can instantiate Python objects based on a __target__: ClimatExML.object.class
style header in the yaml file. https://hydra.cc/docs/advanced/instantiate_objects/overview/
Basically what I'm imaginging is to factor out some of the initalization code in wgan-gp.py
to inherit logical groups of parameters like:
@dataclass
class HyperParams:
batch_sice: int = None
beta: float = 0.1
alpha: float = 10.0
gamma: float = 5.0
which is inherited by
class SuperResolutionWGANGP(pl.LightningModule, HyperParams):
...
instantiate(hyperparams)
Or something. I'm not sure if that synax will work and where exactly to instantiate the object, but something like this will work.