Wrong output from network function, exported from nprtool
이전 댓글 표시
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.
채택된 답변
추가 답변 (2개)
Aneela
2024년 10월 10일
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
praguna manvi
2024년 10월 10일
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!
카테고리
도움말 센터 및 File Exchange에서 Pattern Recognition에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!