hookeai.model_architectures.rnn_base_model.train.training.predict¶
- predict(dataset, model_directory, model=None, predict_directory=None, model_load_state=None, loss_nature='features_out', loss_type='mse', loss_kwargs={}, is_normalized_loss=False, batch_size=1, dataset_file_path=None, device_type='cpu', seed=None, is_verbose=False)[source]¶
Make predictions with recurrent neural network model for given dataset.
- Parameters:
dataset (torch.utils.data.Dataset) – Time series data set. Each sample is stored as a dictionary where each feature (key, str) data is a torch.Tensor(2d) of shape (sequence_length, n_features).
model_directory (str) – Directory where model is stored.
model (GRURNNModel, default=None) – Hybrid material constitutive model. If None, then model is initialized from the initialization file and the state is loaded from the state file. In both cases the model is set to evaluation mode.
predict_directory (str, default=None) – Directory where model predictions results are stored. If None, then all output files are supressed.
model_load_state ({'default', 'init', int, 'best', 'last'},) –
default=’default’ Available model state to be loaded from the model directory. Options:
’default’ : Model default state file
’init’ : Model initial state
int : Model state of given training epoch
’best’ : Model state of best performance
’last’ : Model state of latest training epoch
loss_nature ({'features_out',}, default='features_out') –
Loss nature:
’features_out’ : Based on output features
loss_type ({'mse',}, default='mse') –
Loss function type:
’mse’ : MSE (torch.nn.MSELoss)
loss_kwargs (dict, default={}) – Arguments of torch.nn._Loss initializer.
is_normalized_loss (bool, default=False) – If True, then samples prediction loss are computed from normalized output data, False otherwise. Normalization of output data requires that model data scalers are available.
batch_size (int, default=1) – Number of samples loaded per batch.
dataset_file_path (str, default=None) – Time series data set file path if such file exists. Only used for output purposes.
device_type ({'cpu', 'cuda'}, default='cpu') – Type of device on which torch.Tensor is allocated.
seed (int, default=None) – Seed used to initialize the random number generators of Python and other libraries (e.g., NumPy, PyTorch) for all devices to preserve reproducibility. Does also set workers seed in PyTorch data loaders.
is_verbose (bool, default=False) – If True, enable verbose output.
- Returns:
predict_subdir (str) – Subdirectory where samples predictions results files are stored.
avg_predict_loss (float) – Average prediction loss per sample. Defaults to None if ground-truth is not available for all data set samples.