predictedLabels = scores2label(YTest,classNames);
Show older comments
Dear sir/madam.
predictedLabels = scores2label(YTest,classNames);
Solving XOR problem using QNN. This function i am getting error. like "Unrecognized function or variable 'scores2label'"
Answers (1)
Check Your Version and Toolbox
Run
v = ver;
any(strcmp({v.Name}, 'Deep Learning Toolbox'))
(1 means installed, 0 means not installed) in the MATLAB Command Window to check if Deep Learning Toolbox is installed, and run
license('test', 'Neural_Network_Toolbox')
to check if you have a valid license for it. The answer must be 1 for both calls for using "scores2label".
Another reason for the error could be that you use an older MATLAB version than R2024a when "scores2label" was introduced.
Workaround for Older MATLAB Versions (Pre-R2024a)
If you are on R2023b or earlier, you can replicate scores2label manually by finding the index of the highest score in YTest and mapping it to classNames:
matlab
% Assuming rows of YTest are observations and columns are classes
[~, maxIdx] = max(YTest, [], 2);
predictedLabels = classNames(maxIdx);
(Note: If YTest has classes along the rows instead of columns, change the dimension in max from 2 to 1: max(YTest, [], 1)).
If you are using an older network object (SeriesNetwork or DAGNetwork) rather than a dlnetwork, you can also use the older classify function directly on your test inputs instead of predict + scores2label: [1]
matlab
predictedLabels = classify(net, XTest);
Check for Variable Shadowing
If you are on R2024a+ with the Deep Learning Toolbox installed, make sure you haven't accidentally created a variable or script named scores2label in your workspace or current folder:
matlab
which scores2label -all
If it points to a local file instead of the built-in toolbox directory, rename your local file or clear the variable using clear scores2label.
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!