The following models are implemented in this directory:
- Logistic Regression
- Transformer-Based Encoder(PT-Net) Please refer to the paper for the reasons of why these models are selected.
The final model hyperparameters used are mentioned as the default values in the files.
For details about the individual features in the dataset we curated please look in the wiki.
The directory is structured as follows-
Loader for each dataset returning an array corresponding to the dataset.
Code used to interpolate data to one standard spatial resolution.
Load all data from the datasets using the various dataloaders.
Loader used for linear, unet, unet_lstm models. The loader contains the following Constant values:
these are all the temporal features used for the model prediction. However, the value to be predicted is always deleted before the processing. You can customize this to add/delete datasets for your own experiments
The dataloader supports both pickle and h5 files for the temporal features. The path for the h5 features needs to be provided in the ROOT_DIR and for the pickle features should be provided in the ROOT_DIR_P. Please change the path at the top and provide the directory where the files are located
Currently the only static feature supported is tarnocai, but you can edit the STATIC_FT to add more features The loaders also have the following functions and Classes:
- lpickle : to load the pickle files from filename fname
- get_h5 : read h5 files from file_name fname, you can also provide the optional argument index in case you only want a single index, the default values provided consist of all the features. Provide the optional argument check as True to read temporal files. This function returns the data(i.e the feature values), directly read dates, and dates in the day-month format. In case check is False, the last two are None
This takes in the hyperparameters for constructing the dataset. Iterating over this would provide the spatial, temporal, the ground truth output values when called returns the static and temporal features iteratively. The dataset consists of the folowing feature values that can be accessed from outside the class directly: - num_total_days: the total days in the h5 objects - static: the static features - peat_map : binary map of the peatlands constructed from the tarnocai file - num_temporal: the total number of temporal features - num_static: the total number of static features
This is the pytorch geometric dataset for graph based models. All the functions are similar to the peat_loader file, except the fact that iterating over this will lead to different graphs instead of torch tensors. - peat_gnn : loader used for gnn based models provides different functions for adding different kinds of edges. Currently, only uses peat edges. Greater number of peat edges will require higher compute facilities
This folder contains all the relevant models with the exxeption of transformers(due to the different nature of the model). For the Transformer model, please refer to Transformers.ipynb. It must be noted that we still use the same dataset for both the models.
Regular Linear Regression based model. This model regards both spatial information in the batch dimension and each feature consists of both the temporal and spatial values.
This is a helper class that provides the downsampling and the upsampling blocks for the unet architectures
A regular UNet Architecture consists of multiple downsampling blocks followed by upsampling blocks. Here each feature is considered as a different channel.
unet augmented with a LSTM layer at the end to allow for temporal information to be processed differently.
model that first produces a gnn encoding and then produces the output
relational gnn model used to process differnt kinds of edges(requires high compute power)
train file for UNet, UNet-LSTM, Linear regression
train file for gnn based architecture
Please follow the following steps to run the code:
- Install required packages: - pytorch - pytorch geometric - skikit - matplotlib - simplejson
python [train.py/train_gnn.py] --model <name of model> --conf f --dmodel <hyperparameter for num features> --lr <learning rate> --in_days <num of in days> --out_days <num of out days> --out <feature to output: CO2/CWFIS>
You can also pass in the hyperparameters in the form of a yaml file, in which case use --conf y --output_dir . This is useful in cases where you want to run a grid search.
Follow the following steps to create a new model to test The name of the model should be the same as the file name in Model
To add additional models, follow the following steps:
- add file in model directory
- name the class as Model
- add code for the initialization in train.py/train_gnn.py