I am using the following code to classify data with a neural network. I first classify the data with the network, then round the output and then convert the vector to an integer (i.e. 1,2,3).
output = sim(net, tmparray); outputrounded = round(output); result = vec2ind(outputrounded);
However, sometimes the NN cannot match the input to a particular target,so when the output is rounded they are all zeros, so when it is converted from a vector to an integer there is no output.
If this happens is there anyway to force the result to be a zero?
The reason I ask is because when you are classifying thousands of samples one after another and one sample cannot be classified and there is no result , it is very difficult to identify which input resulted in this.
No products are associated with this question.
Replace the vec2ind() with matrix multiplication.
mvec = 1 : size(outputrounded,1); result = mvec(:) * outputrounded;
For classification of c mutually exclusive classes, use a target matrix consisting of the columns of the c-dimensional unit matrix eye(c).
Use softmax as the output activation function. Then all outputs are in the OPEN interval (0,1) and sum to 1.
classindices = [ 4 2 3 1 2]
target = ind2vec(classindices)
target = full(target)
output = softmax(target+0.3*randn(4,5))
predclass = vec2ind(output)
Err = predclass~=classindices
If the classes are NOT mutually exclusive (e.g., tall,dark,handsome), use logsig as the output activation function. Then all outputs are in the OPEN interval (0,1) but do NOT sum to 1.
Outputs of exactly 0 or 1 are the results of floating point error.
target = round(rand(3,5))
output = logsig(target+0.4*randn(3,5))
predclasses = round(output)
Err = predclasses-target
Nerrs = sum(Err,2)
Hope this helps.