clarity.evaluator.haspi.ip module

Functions for HASPI neural network stage.

clarity.evaluator.haspi.ip.get_neural_net() tuple[dict, list[ndarray], list[ndarray], float][source]

Provide the weights derived for the ensemble of ten neural networks used for the HASPI_v2 intelligibility model. The neural networks have ten inputs, 4 neurons in the hidden layer, and one output neuron. The logsig activation function is used.

Arguments: None

Returned values:

neural_net_params (dict): parameters defining the neural network weights_hidden (): cell array 10 x 1 for the weights linking the input to the hidden layer. Each cell is a 11 x 4 matrix of weights weights_out (): call array 5 x 1 for the weights linking the hidden to the

output layer. Each cell is a 5 x 1 vector of weights.

normalization_factor (): normalization so that the maximum neural net output is

exactly 1.

Updates:

James M. Kates, 8 October 2019. Version for new neural network using actual TFS scores, 24 October 2019. Translated from MATLAB to Python by Zuzanna Podwinska, March 2022.

clarity.evaluator.haspi.ip.nn_feed_forward(data: ndarray, neural_net_params: dict, weights_hidden: ndarray, weights_out: ndarray) tuple[ndarray, ndarray][source]

Compute the outputs at each layer of a neural network given the input to the network and the weights. The activation function is an offset logistic function that gives either a logsig or hyperbolic tangent; the outputs from each layer have been reduced by the offset. The structure of the network is an input layer, one hidden layer, and an output layer. The first values in vectors hidden and output are set to 1 by the function, and the remaining values correspond to the outputs at each neuron in the layer.

Args: data (np.ndarray): feature vector input to the neural network. neural_net_params (dict): network parameters from get_neural_net(). weights_hidden (list): matrix of weights for the hidden layer. weights_out (list): matrix of weights for the output layer.

Returns: hidden (): vector of outputs from the hidden layer. output (): vector of outputs from the output layer.

Updates: James M. Kates, 26 October 2010. Translated from MATLAB to Python by Zuzanna Podwinska, March 2022.

clarity.evaluator.haspi.ip.nn_feed_forward_ensemble(data: ndarray, neural_net_params: dict, weights_hidden: list[ndarray], weights_out: list[ndarray]) ndarray[source]

Function to compute the neural network ensemble response to a set of inputs. The neural network is defined in NNfeedforwardZ.

Args: data (np.ndarray): array of features input to the neural network neural_net_params (dict): vector of neural network parameters weights_hidden (list): cell array of hidden layer weights for each network weights_out (list): cell array of output layer weights for each network

Returns: model neural network output vector averaged over the ensemble

Updates: James M. Kates, 20 September 2011. Translated from MATLAB to Python by Zuzanna Podwinska, March 2022.