# How to convert the complex number as a 2D vector to train a neural network

20 visualizzazioni (ultimi 30 giorni)
tyler seudath il 26 Nov 2021
Commentato: Walter Roberson il 26 Nov 2021
Dear all,
I have a 4050 segment x 400 samples which are complex numbers. In order to train the neural network I need to split the data into a 2D real and imaginary and then create a 4D array that is accepted by the network to train. Any idea how to go about this?
Best,
Tyler
##### 3 CommentiMostra 1 commento meno recenteNascondi 1 commento meno recente
tyler seudath il 26 Nov 2021
Could you explain this a little more, I dont understand. This is the code I have thus far,
RealTrain_data = real(cell2mat(Train_inputX1));
ImTrain_data = imag(cell2mat(Train_inputX1));
TrainInput = [RealTrain_data ImTrain_data];
So for the 4D array will it be [row column channels TrainInput]??
So for the 4D array will it be [ row column channels TrainInput]?
Sorry I am new to this.
Walter Roberson il 26 Nov 2021
You have a two dimensional array; call it Data for the moment. The rows correspond to different segments and the columns correspond to different samples, so Data(SegmentNumber, SampleNumber) is one piece of information. That information has a real and an imaginary part, so you have real(Data(SegmentNumber, SampleNumber)) and imag(Data(SegmentNumber, SampleNumber)) . So you have number of segments times number of samples times two (real + imaginary) pieces of information overall.
But to store number of segments by number of samples by two pieces of information, you can store that in an array that is (NumberOfSegments by NumberOfSamples by 2) large:
DataParts = zeros(size(Data,1), size(Data,2), 2);
DataParts(:,:,1) = real(Data);
DataParts(:,:,2) = imag(Data);
then DataParts(J,K,1) is real(Data(J,K)) and DataParts(J,K,2) is imag(Data(J,K)) . So you have managed to store all of the data into a three dimensional array.
Do you need 4 dimensions? You only need four dimensions if you have four independent variables: DataParts(SegmentNumber, SampleNumber, RealOrImaginaryPane, WHAT_IS_THIS_DIMENSION)
Sometimes though what you might need would be
DataParts = zeros(size(Data,1), size(Data,2), 1, 2);
DataParts(:,:,:, 1) = real(Data);
DataParts(:,:,:, 2) = imag(Data);
which would be NumberOfSegments by NumberOfSamples by 1 by 2. The 1 here would correspond to number of colour planes, but you only have one color plane.

Accedi per commentare.

### Risposte (1)

KSSV il 26 Nov 2021
To get real and imaginary part of the complex number, use real and imag. For other part use reshape.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Image Data Workflows in Help Center e File Exchange

R2021a

### Community Treasure Hunt

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

Start Hunting!

Translated by