Stability Scheduling

Created on Sat May 13 10:12:56 2023

@author: WET2RNG

softsensor.stab_scheduler.Stability_Criterion(Network)[source]

Defined stability criterion for Autoregressive Neural Networks. If criterion < 0 Network is Input to state stable according to: https://www.researchgate.net/publication/346701375_Stability_of_discrete-time_feed-forward_neural_networks_in_NARX_configuration

Parameters:

Network (torch Network) – Neural Network with function Network.get_recurretn_weights.

Raises:

Warning – if activation function is not defined with Lipschitz constant explicitly.

Returns:

stabiliyt criterion for the Network.

Return type:

float

class softsensor.stab_scheduler.Stability_Loss(criterion, DNN, stabelizer=0, local_wd=0)[source]

Callable loss function to train for accuracy and stability of an autoregressive Network at the same time

Parameters:
  • criterion (nn.Loss, optional) – Loss function for training. e.g. nn.MSELoss().

  • DNN (torch Network) – Neural Network with function Network.get_recurretn_weights.

  • stabelizer (float, optional) – added stability parameter applied to recurrent weights. The default is 0.

  • local_wd (float, optional) – added local weight decay parameter applied to recurrent weights. The default is 0.

Return type:

None.

forward(y_pred, y)[source]

Forward function for the defined loss between the prediction y_pred and y with added stabelization term

Parameters:
  • y_pred (torch.tensor) – predicted values.

  • y (torch.tensor) – true values.

Returns:

loss – loss between y_pred and y.

Return type:

torch.tensor

softsensor.stab_scheduler.arnn_threshold(arnn)[source]

function to compute the specific lower limit for the stability of an arnn

Parameters:

arnn (ARNN Model) – ARNN according to softsensor.autoregr_models design

Raises:

Warning – if the activation function is not implemendet. currently implemented are: [‘tanh’, ‘relu’, ‘leaky_relu’, ‘sine’]

Returns:

kappa – lower limit for the stability of an arnn.

Return type:

float

class softsensor.stab_scheduler.const_stab(s1=0.1, track=True, track_n=1)[source]

Stability score scheduler that returns a constant value

Parameters:
  • s1 (float, optional) – the constant weight to be returned. The default is 0.1.

  • track (Bool, optional) – if True the values are tracked in a dict. The default is True.

Return type:

None.

get_stab(model=None)[source]

call method to get stability parameter

Parameters:

model (ARNN Model, optional) – Not needed, optional Parameter to be consistant with other stability schedulers. The default is None.

Returns:

s1 value.

Return type:

float

softsensor.stab_scheduler.get_scheduler(stab_method, model, s1=0.01, s0=1e-08, m=None, track=True, track_n=100)[source]

wrapper function to get the specific scheduler by name

Parameters:
  • stab_method (str or float or None) – defines the specific Method. implemented str: [‘const’, ‘lin’, ‘log_lin’, ‘heaviside’] float value returnes the same scheduler as ‘const’

  • arnn (torch Network) – Neural Network with function Network.get_recurretn_weights.

  • s1 (float, optional) – scheduler specific parameter. The default is 1e-2.

  • s0 (float, optional) – scheduler specific parameter. The default is 1e-8.

  • m (float, optional) – scheduler specific parameter. The default is None.

  • track (Bool, optional) – if True the values are tracked in a dict. The default is True.

Raises:

Warning – if invalid stab_method is given

Returns:

stab scheduler Method.

Return type:

class

class softsensor.stab_scheduler.heaviside_stab(s1=0.01, track=True, track_n=1)[source]

Stability score scheduler designed as a heaviside funciton with value s1 at stability score greater zero If criterion < 0 Network is Input to state stable according to: https://www.researchgate.net/publication/346701375_Stability_of_discrete-time_feed-forward_neural_networks_in_NARX_configuration

Parameters:
  • model (ARNN) – ARNN according to softsensor.autoregr_models design

  • s1 (float, optional) – stability parameter at stability score zero, The default is 1e-2.

  • track (Bool, optional) – if True the values are tracked in a dict. The default is True.

Return type:

None.

get_stab(model, sc=None)[source]

call method to get stability parameter

Parameters:
  • model (ARNN Model) – ARNN according to softsensor.autoregr_models design

  • sc (float or None, optional) – stability score to evaluate function at, if None is given computes stability with method Stability_Criterion(model) The default is None.

Returns:

st – stablizer according to the linear function

Return type:

float

class softsensor.stab_scheduler.linear_stab(model, s1=0.01, track=True, track_n=1)[source]

Stability score scheduler designed as a linear funciton with value s1 at stability score zero eta = m*x + s1 m = s1 / (Network specific threshold) If criterion < 0 Network is Input to state stable according to: https://www.researchgate.net/publication/346701375_Stability_of_discrete-time_feed-forward_neural_networks_in_NARX_configuration

Parameters:
  • model (ARNN) – ARNN according to softsensor.autoregr_models design

  • s1 (float, optional) – stability parameter at stability score zero

  • track (Bool, optional) – if True the values are tracked in a dict. The default is True.

Return type:

None.

get_stab(model, sc=None)[source]

call method to get stability parameter

Parameters:
  • model (ARNN Model) – ARNN according to softsensor.autoregr_models design

  • sc (float or None, optional) – stability score to evaluate function at, if None is given computes stability with method Stability_Criterion(model) The default is None.

Returns:

st – stablizer according to the linear function

Return type:

float

softsensor.stab_scheduler.local_weight_decay(Network)[source]

Defined local weight decay for Autoregressive Neural Networks.

Parameters:

Network (torch Network) – Neural Network with function Network.get_recurretn_weights.

Returns:

mult_weight_norm – local weigth decay of the Network.

Return type:

float

softsensor.stab_scheduler.local_weight_product(Network)[source]

Defines the product of the norm of the recurrent wegiths in a defined Network

Parameters:

Network (Torch Neural Network) – Neural Network with function Network.get_recurretn_weights.

Returns:

mult_weight_norm – product of the recurrent weight norm.

Return type:

float

class softsensor.stab_scheduler.log_lin_stab(arnn, s0=1e-06, s1=0.001, m=None, track=True, track_n=1)[source]

Stability score scheduler designed as an exponential function up to a stability criterion of zero and a linear function afterwards If criterion < 0 Network is Input to state stable according to: https://www.researchgate.net/publication/346701375_Stability_of_discrete-time_feed-forward_neural_networks_in_NARX_configuration

Parameters:
  • model (ARNN) – ARNN according to softsensor.autoregr_models design

  • s0 (float, optional) – stability parameter at the lower Networkspecific threshold, The default is 1e-6.

  • s1 (float, optional) – stability parameter at stability score zero,The default is 1e-3.

  • m (float, optional) – gradient of the linear function between [0, inf]. If None is given, use the gradient of the exponential function. The default is None.

  • track (Bool, optional) – if True the values are tracked in a dict. The default is True.

Return type:

None.

get_stab(model, sc=None)[source]

call method to get stability parameter

Parameters:

model (ARNN Model) – ARNN according to softsensor.autoregr_models design

Returns:

  • st (float) – stablizer according to the linear function

  • sc (float or None, optional) – stability score to evaluate function at, if None is given computes stability with method Stability_Criterion(model) The default is None.

class softsensor.stab_scheduler.none_stab(track=True, track_n=1)[source]

Stability score scheduler that returns a None

Parameters:

track (Bool, optional) – if True the values are tracked in a dict. The default is True.

Return type:

None.

get_stab(model=None)[source]

call method to get stability parameter

Parameters:

model (ARNN Model, optional) – Not needed, optional Parameter to be consistant with other stability schedulers. The default is None.

Return type:

None