sup3r.models.abstract.AbstractInterface
- class AbstractInterface[source]
Bases:
ABC
Abstract class to define the required interface for Sup3r model subclasses
Note that this only sets the required interfaces for a GAN that can be loaded from disk and used to predict synthetic outputs. The interface for models that can be trained will be set in another class.
Methods
generate
(low_res[, norm_in, un_norm_out, ...])Use the generator model to generate high res data from low res input.
Compute factor by which model will enhance spatial resolution from layer attributes.
Compute factor by which model will enhance temporal resolution from layer attributes.
load
(model_dir[, verbose])Load the GAN with its sub-networks from a previously saved-to output directory.
save_params
(out_dir)seed
([s])Set the random seed for reproducible results.
set_model_params
(**kwargs)Set parameters used for training the model
Attributes
Get list of high-resolution exogenous filter names the model uses.
Get the list of high-resolution output feature names that the generative model outputs.
Get dimension of model generator input.
'...km', 'temporal': '...min'}.
Check if model expects spatial only input
Check if model expects spatiotemporal input
Get a list of low-resolution features input to the generative model.
Get meta data dictionary that defines how the model was created
Model parameters, used to save model to disc
Resolution of output data.
Factor by which model will enhance spatial resolution.
Get the list of smoothed input feature names that the generative model was trained on.
Value of smoothing parameter used in gaussian filtering of coarsened high res data.
Factor by which model will enhance temporal resolution.
A record of important versions that this model was built with.
- abstract classmethod load(model_dir, verbose=True)[source]
Load the GAN with its sub-networks from a previously saved-to output directory.
- Parameters:
model_dir – Directory to load GAN model files from.
verbose (bool) – Flag to log information about the loaded model.
- Returns:
out (BaseModel) – Returns a pretrained gan model that was previously saved to model_dir
- abstract generate(low_res, norm_in=True, un_norm_out=True, exogenous_data=None)[source]
Use the generator model to generate high res data from low res input. This is the public generate function.
- static seed(s=0)[source]
Set the random seed for reproducible results.
- Parameters:
s (int) – Random seed
- property input_dims
Get dimension of model generator input. This is usually 4D for spatial models and 5D for spatiotemporal models. This gives the input to the first step if the model is multi-step. Returns 5 for linear models.
- Returns:
int
- property is_5d
Check if model expects spatiotemporal input
- property is_4d
Check if model expects spatial only input
- get_s_enhance_from_layers()[source]
Compute factor by which model will enhance spatial resolution from layer attributes. Used in model training during high res coarsening
- get_t_enhance_from_layers()[source]
Compute factor by which model will enhance temporal resolution from layer attributes. Used in model training during high res coarsening
- property s_enhance
Factor by which model will enhance spatial resolution. Used in model training during high res coarsening
- property t_enhance
Factor by which model will enhance temporal resolution. Used in model training during high res coarsening
- property input_resolution
‘…km’, ‘temporal’: ‘…min’}. The numbers are required to be integers in the units specified. The units are not strict as long as the resolution of the exogenous data, when extracting exogenous data, is specified in the same units.
- Type:
Resolution of input data. Given as a dictionary {‘spatial’
- property output_resolution
Resolution of output data. Given as a dictionary {‘spatial’: ‘…km’, ‘temporal’: ‘…min’}. This is computed from the input resolution and the enhancement factors.
- abstract property meta
Get meta data dictionary that defines how the model was created
- property lr_features
Get a list of low-resolution features input to the generative model. This includes low-resolution features that might be supplied exogenously at inference time but that were in the low-res batches during training
- property hr_out_features
Get the list of high-resolution output feature names that the generative model outputs.
- property hr_exo_features
Get list of high-resolution exogenous filter names the model uses. If the model has N concat or add layers this list will be the last N features in the training features list. The ordering is assumed to be the same as the order of concat or add layers. If training features is […, topo, sza], and the model has 2 concat or add layers, exo features will be [topo, sza]. Topo will then be used in the first concat layer and sza will be used in the second
- property smoothing
Value of smoothing parameter used in gaussian filtering of coarsened high res data.
- property smoothed_features
Get the list of smoothed input feature names that the generative model was trained on.
- property model_params
Model parameters, used to save model to disc
- Returns:
dict
- property version_record
A record of important versions that this model was built with.
- Returns:
dict