Extend the labels array to full 2D area
1 回表示 (過去 30 日間)
古いコメントを表示
I have a 2D data 460by950 and I reshaped it to 10by10by4370 and used it for Testing my network. The input is 10by10 matrix and the output is one label array 4370by1 categorical. I need to expand these labels to the original data size 460by950. data=reshape(data,10,10,[]); dim3= size(data,3); Label=[]; for i=1:dim3 YPred= classify(net,data(:,:,i)); Label=[Label;YPred]; end
2 件のコメント
Benjamin Thompson
2022 年 7 月 29 日
So reshape does not work to change to 460x950? Can you attach a file that defines the net and xx variables so that the Community can also run your sample code?
回答 (1 件)
Hari
2023 年 9 月 11 日
Hi Amen,
As per my understanding, you have a 2D data array with dimensions 460x950. You reshaped this array into a 3D array with dimensions 10x10x4370. You want to use this reshaped data for testing your network. The input to the network is a 10x10 matrix, and the output is a label array with dimensions 4370x1 (categorical). You need to expand these labels to match the original data size of 460x950.
From the line “Label=[Label;YPred];” in your code, I have seen that you are adding each of your prediction to the “Label” vector each time. This creates a column vector of the predicted labels for the input 10x10 matrices but doesn’t expand the labels array to full 2D input. For the expansion of the Labels, you can use “repmat” function in MATLAB.
Expanded_label = repmat(YPred, 46, 95); % Expand labels to match original size
After predicting the label for each input matrix, use the “repmat” function to expand the predicted label “YPred”. By repeating the label 46 times vertically and 95 times horizontally, we can match the original data size of 460x950. This ensures that each element in the expanded Label array corresponds to the predicted label for the corresponding element in the original data.
Refer to the below documentation to learn more about “repmat” function in MATLAB.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Image Data Workflows についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!