Update Strategies

This module contains the implementations of the parameter update strategies used in the training of ANFIS models.

OLS Estimation for Consequents

neuro_fuzzy_toolbox.training.update_strategies.classical_consequents_estimation_with_OLS(ANFISmodel, loader, driver, ridge_lambda)[source]

Estimates the consequent parameters of an ANFIS model using ordinary least squares.

Note

Specifically, QR decomposition with pivoting is used to solve the least-squares problem. For more information, see: https://pytorch.org/docs/stable/generated/torch.linalg.lstsq.html.

Parameters:
  • ANFISmodel (ANFIS | h_ANFIS) – ANFIS model whose consequent parameters are to be estimated.

  • loader (DataLoader) – DataLoader containing the training data.

  • driver (str) – Backend function to use for the least-squares estimation. Valid values are 'gels', 'gelsy', 'gelsd', and 'gelss'. If None, defaults to 'gels'.

  • ridge_lambda (float) – Lambda value for Ridge regularization in the least-squares estimation. If 0., no regularization is applied.

Returns:

Tensor containing the new consequent parameters.

Return type:

torch.Tensor

Optimizer Training Epoch

neuro_fuzzy_toolbox.training.update_strategies.optimizer_training_epoch(model, loader, optimizer, loss_function)[source]

Updates the parameters of a model for one training epoch using a given optimizer and loss function. The parameters to be updated are determined by the optimizer.

Parameters:
  • model (ANFIS | h_ANFIS | rule_reduced_ANFIS) – ANFIS model to train.

  • loader (DataLoader) – DataLoader containing the training data.

  • optimizer (torch.optim.Optimizer) – Instantiated optimizer to use.

  • loss_function (torch.nn.Module) – Loss function to use.