Time series training using 2D CNN

Hi ,
I am trying to use 2D CNN to train and then predict time series (specifically analog signal splitted into 5 samples each sequence ---> the whole input matrix is Nx5) ...
Though i defined 4d matrices XTrain and YTrain for trainNetwork() function as follows :
... COMMENTS ...
I defently defined 4d matrix with images 1xchannel_length but still getting the error below :
"
>> MatlabNnPilot
155 net = trainNetwork(XTrain,YTrain,layers,options);
Error using trainNetwork (line 165)
Invalid training data. X must be a 4-D array of images.
Error in MatlabNnPilot (line 155)
net = trainNetwork(XTrain,YTrain,layers,options);
"
Please advise how to resovle it if possible ?
Igor

1 件のコメント

igor Lisogursky
igor Lisogursky 2020 年 9 月 27 日
As well attaching here the sizes of XTrain and YTrain from the same code :

サインインしてコメントする。

回答 (1 件)

Srivardhan Gadila
Srivardhan Gadila 2020 年 9 月 28 日

1 投票

I tried the following code which is written based on the above mentioned code & I'm not getting any errors. You can refer to the net = trainNetwork(X,Y,layers,options) syntax and also it's corresponding Input Arguments description.
Try checking the following code once:
input_size = 5;
output_size = 1;
numHiddenUnits = 32;
epochs = 50;
nTrainSamples = 40725;
layers = [ ...
imageInputLayer([1 input_size 1],'Name','input')
convolution2dLayer([1 input_size],1,'Name','conv')
batchNormalizationLayer('Name','bn')
reluLayer('Name','relu')
fullyConnectedLayer(output_size, 'Name','fc')
regressionLayer('Name','regression')];
% lgraph = layerGraph(layers);
% analyzeNetwork(layers)
%%
trainData = randn([1 5 1 nTrainSamples]);
% trainLabels = randn(nTrainSamples,numClasses);
trainLabels = randn([1 1 1 nTrainSamples]);
size(trainData)
size(trainLabels)
%%
options = trainingOptions('adam', ...
'InitialLearnRate',0.005, ...
'ValidationData',{trainData,trainLabels},...
'LearnRateSchedule','piecewise',...
'MaxEpochs',epochs, ...
'MiniBatchSize',32, ...
'Verbose',1, ...
'Plots','training-progress');
net = trainNetwork(trainData,trainLabels,layers,options);

5 件のコメント

igor Lisogursky
igor Lisogursky 2020 年 9 月 28 日
Thanks for the answer ...i ran your code and indeed all went smooth , apperantly my issue was that the signal (aka time series ) was complex ...It worked after aplling real() elementwise
I assume NN in matlab does not support complex format
Srivardhan Gadila
Srivardhan Gadila 2020 年 9 月 29 日
@igor Lisogursky, alternatively you can use the imageInputLayer with 1x5x2 or 2x5x1 etc as input size i.e., seperate the real & complex data and combine them along channel dimension (1x5x2) or add a row (2x5x1) such that the first row of the input would be real data and the second row would be the complex data. The similar idea is implemented in the following example: Modulation Classification with Deep Learning.
igor Lisogursky
igor Lisogursky 2020 年 10 月 6 日
Hi @Srivardhan Gadila Got you ... If i am choosing the 1x5x2 option since i want different filters(weights) convolving with each part (feature/channel), what would be the size of the network output for filter size 1x5 and FilterNum=2 ... I am not sure would it be Nx1x2? While N is the number of sequences 1x5x2
Srivardhan Gadila
Srivardhan Gadila 2020 年 10 月 6 日
@igor Lisogursky, you can verify the same by creating your network and using analyzeNetwork function to view the shape of the activations after each layer.
igor Lisogursky
igor Lisogursky 2020 年 10 月 9 日
Thanks @Srivardhan Gadila for a responde it will be usefull func

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

質問済み:

2020 年 9 月 23 日

コメント済み:

2020 年 10 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by