MATLAB: Is it possible to impose constraints on a neural network using Neural Network Toolbox

Deep Learning Toolbox

I would like to impose constraints during the training phase of a neural network. In other words, in addition to providing the inputs and target data, I would also specify, for example, that the derivative of the neural network's outputs with respect to a certain input variable should always be positive.

Best Answer

There is no way to impose derivative constraints on a neural network using Neural Network Toolbox.
The four constraint types that are supported are:
1) The standard error performance constraints.
2) Constraints that hold entire weight matrices and/or bias vectors to be constant by turning off their learning, using commands such as:
net.inputWeights{i,j}.learn = false;
net.layerWeights{i,j}.learn = false;
net.biases{i}.learn = false
3) Constraints that minimize the mean squared sum of weights and biases, in addition to
minimizing the error, by using a performance function with regularization (for instance, the MSEREG or MSNEREG functions). These can be set with commands like:
net.performFcn = 'msereg';
4) Constraints that minimize the mean squared outputs. This is useful for problems where solutions with low network output are preferred. For instance, a neural network being used as a controller may demand less power if it solves the problem with lower outputs. The performance function for this is MSEREGEC and can be set with a command like:
net.performFcn = 'mseregec';