Converting training inputs to 4D array
25 views (last 30 days)
Show older comments
tyler seudath on 26 Nov 2021
Commented: tyler seudath on 1 Dec 2021
I need to convert my training data which comprise real and imaginary values into a 4D matrix and I am getting trouble.
Here is the line of code I did so far with the data:
Train_inputX1 =All_data_segments; %5000 segments x 400 samples
Train_outputX1 =Modulation_Schemes ;% 5000 segments x 1
Test_X1 =ceil(0.1 *size(All_data_segments,1)); % 10% is catered for testing
idx1_t= randperm(size(All_data_segments,1),Test_X1);%This will generate the 10% of the random test numbers from 1 to 5000
% % Now I'm gonna partition the data accordingly...
testX1_input = All_data_segments(idx1_t',:); %Phase test input
testX1_output = Modulation_Schemes(idx1_t); %Phase test output
Train_inputX1(idx1_t',:) = ; % assigning '' to matrix entries deletes them.
Train_outputX1(idx1_t',:) =; % Deletes the outputs that was used to test input
% %Now we need to repeat to find the validation data
Train1_inputX1 = Train_inputX1; %5000 segments x 400 samples
Train1_outputX1 =Train_outputX1;% 5000 segments x 1
Val_X1 =ceil(0.1 *size(Train_outputX1,1)); % 10% is catered for Validation
idx1_v= randperm(size(Train_outputX1,1),Val_X1);%This will generate the 10% of the random test numbers from 1 to 5000
% Now I'm gonna partition the data accordingly...
ValX1_input =Train1_inputX1(idx1_v',:); %Val input
ValX1_output =Train_outputX1(idx1_v); % Val output
Train1_inputX1(idx1_v',:) = ; % assigning '' to matrix entries deletes them.
Train1_outputX1(idx1_v',:) =; % Deletes the outputs that was used to validation input
RealTrain_data = real(cell2mat(Train_inputX1));
ImTrain_data = Imag(cell2mat(Train_inputX1));
RealTest_data = real(cell2mat(testX1_input));
ImTest_data = Imag(cell2mat(testX1_inputX1));
RealVal_data = real(cell2mat(ValX1_input));
ImVal_data = Imag(cell2mat(ValX1_input));
Train_output = categorical(Train1_outputX1); %4050 segments
Test_output = categorical(testX1_output); % 500 segments
Val_output =categorical(ValX1_output);%450 segments
could you assist in converting the training, val and test input data into 4D arrays which comprise both real and imaginary parts
I am trying to build a sequence to 1 CNN to match the inputs to the corresponding modulation scheme
Thanks in advance
Shivam Singh on 30 Nov 2021
You should keep the "XTrain", "Ttrain" and "Vtrain" as double array only, and don’t convert it into cell array using “num2cell” function. So, the "XTrain" will be a double array of size= [400, 1, 2, 4500], "Ttrain" will be a double array of size= [400, 1, 2,500] and "Vtrain" will be a double array of size= [400, 1, 2, 450]
Also, you should keep the last layer of your network architecture as :
fullyConnectedLayer (number of categories in “Trainoutfinal”)
More Answers (0)
Find more on Image Data Workflows 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!