Wrong output from network function, exported from nprtool
Afficher commentaires plus anciens
Trained a neural pattern recognition network (nprtool) using 4x23458 Matrix as the predictors. The target is boolean. I was happy with the results and exported the function into workspace:
function [y1] = myNeuralNetworkFunction(x1)
Now its returning double instead of boolean if i feed it with a sample of the training data. Im quite sure there is an easy fix to this. Really a novice in using neural network functions in matlab.
Thank you.
Réponse acceptée
Plus de réponses (2)
Aneela
le 10 Oct 2024
Hi Thomas,
When you train a neural network for binary classification using MATLAB's Neural Pattern Recognition Tool (nprtool), the network outputs a continuous value. This value typically ranges between 0 and 1, representing the probability that the input belongs to the positive class.
To convert the continuous output to a Boolean value, you can apply a threshold.
output = myNeuralNetworkFunction(x1);
booleanOutput = output >= 0.5;
This operation will return 1 for values(probabilities) greater than or equal to 0.5 and 0 otherwise.
You can refer to the documentation below for more information on “nprtool”: https://www.mathworks.com/help/deeplearning/gs/pattern-recognition-with-a-shallow-neural-network.html
1 commentaire
Thomas
le 10 Oct 2024
praguna manvi
le 10 Oct 2024
As I understand it, you are trying to predict the class using the trained “patternnet” loaded from workspace. To convert the double values from the network to class labels, you can use the “vec2ind” function and “ind2vec” to obtain a sparse vector output. Here is an example from the documentation of “patternnet”:
y = net(x);
tind = vec2ind(t); % test outputs
yind = vec2ind(y);
percentErrors = sum(tind ~= yind) / numel(tind);`
For more information on how to use “patternnet” from the command line, please refer to this link:
Hope this helps!
1 commentaire
Thomas
le 10 Oct 2024
Catégories
En savoir plus sur Pattern Recognition dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!