training

Functions

begin_training(savedir, stage, xtrain, ytrain, xvalid, ...)

Begin training the Unet model.

make_predictions(uarr, unet, config_dict, config_path, ...)

Prepare the input data for the model.

Module Contents

training.begin_training(savedir, stage, xtrain, ytrain, xvalid, yvalid, unet, batch_size=30, n_epochs=250, save_format='keras')

Begin training the Unet model.

Parameters:
  • savedir (str) – Directory to save outputs.

  • stage (int) – The stage number (1 or 2).

  • xtrain (np.ndarray) – Training input features.

  • ytrain (np.ndarray) – Training target variables.

  • xvalid (np.ndarray) – Validation input features.

  • yvalid (np.ndarray) – Validation target variables.

  • unet (Unet) – The Unet model to be trained.

  • batch_size (int, optional) – Batch size for training.

  • n_epochs (int, optional) – Number of epochs for training.

  • save_format (str, optional) – Format to save the model (‘h5’, ‘keras’, or ‘both’).

Returns:

unet – The trained Unet model.

Return type:

Unet

training.make_predictions(uarr, unet, config_dict, config_path, output_metadata, stage=1)

Prepare the input data for the model.

Get the training data from the input NetCDF dataset as numpy arrays and concatenate them along the time dimension.

Parameters:
  • uarr (unox.uarray) – The dataset of the input NetCDF file.

  • unet (Unet) – The Unet model to be trained.

  • config_dict (dict) – A dictionary containing the configuration.

  • config_path (str) – Path to the input configuration JSON file used to make config_dict.

  • output_metadata (dict) – The dictionary of metadata describing the output of a model run.

  • stage (int) – The stage of the data to plot (1 or 2).

Returns:

  • xtrain (np.ndarray) – Concatenated training input features.

  • ytrain (np.ndarray) – Concatenated training target variables.

  • output_metadata (dict) – The dictionary of metadata describing the output of a model run with values added for train_years and unet_build_shape.