필터 지우기
필터 지우기

Extend the labels array to full 2D area

조회 수: 3 (최근 30일)
AMEN BARGEES
AMEN BARGEES 2022년 7월 29일
답변: Hari 2023년 9월 11일

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
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?
AMEN BARGEES
AMEN BARGEES 2022년 7월 29일
It can be reshaped to 46by95 but its something different, maybe because of the way I am using to input my data.

댓글을 달려면 로그인하십시오.

답변 (1개)

Hari
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 userepmat” 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.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by