sensitivity of neural network in matlab

To perform sensitivity analysis for a neural network in MATLAB, one approach would be to use the MathWorks' Neural Network Toolbox. This toolbox provides functions to create and train neural networks, as well as tools for analyzing their performance.

To perform sensitivity analysis, one could use the toolbox's sensdiff function. This function computes and returns the sensitivities of the network's output with respect to its input, for a given set of input values. The sensdiff function takes the following arguments:

main.m
sensdiff(net, inputs, errors)
30 chars
2 lines

where net is the neural network object, inputs is a matrix of input values for which to compute sensitivities, and errors is a matrix of associated errors.

Here's an example usage of sensdiff:

main.m
% Create and train a neural network
inputs = rand(10, 100);   % 10 input neurons and 100 training samples
targets = rand(1, 100);   % 1 output neuron and 100 training samples
net = feedforwardnet(5);  % 5 hidden neurons
net = train(net, inputs, targets);

% Generate some test inputs
test_inputs = rand(10, 5);

% Compute sensitivities for the test inputs
errors = rand(1, 5);
sensitivities = sensdiff(net, test_inputs, errors);
429 chars
13 lines

This will compute the sensitivities of the network's output with respect to its inputs for 5 test input samples, using random error values. The sensitivities will be returned as a matrix of the same size as the input matrix.

Note that the sensitivities calculated by sensdiff are local sensitivities, meaning they approximate the effect of a small perturbation in the inputs around the given values. To obtain more accurate global sensitivities, one could use methods such as Monte Carlo sampling or gradient-based optimization.

gistlibby LogSnag