How to input a .xsls file having 7081*9 dimension as a datastore input to deep learning designer app in MATLAB

4 visualizaciones (últimos 30 días)
I am having my input data in .xlsx file. it's dimention is 7081*9, where the number of columns represents 9 different features. All the data are numeric values. I have attached some part of my data with this question.
My aim is to designa LSTM based deep learning network using deep learning network designer app in MATLAB. The input size of my input sequential layer is 8 and output size of final layer is one. In my input data, first 8 columns are the input features and the final column is the response or output.
When I convert that .xlsx file into spreadsheet datastore and import to deep learning designer app, it previews the data of 5*9 dimension. But when I train the network, it shows an error as " Your input data is having dimension one, but input sequence layer expects the input of 8 layers ".
I don't know where I am getting wrong. So kindly, help me in this matter. It will be great help.
Also, If someone can tell me, for the numeric input data type which are saved as an excel sheet, which datastore type is a suitable one for them to be used as multi feature input data in deep learning designer app. Any example or online document is which address my problem, if anyone can share, I will be highly grateful.

Respuestas (1)

Katja Mogalle
Katja Mogalle el 22 de Jun. de 2022
When using the spreadsheetDatastore as is, the data will be read as a table with 9 columns (8 features and one response) and 7081 rows (I assume these are the elements of the sequence, e.g. "time steps"). I also assume that the whole spreadsheet constitutes one observation. I'm not sure if you have more spreadsheets with other observations.
If you want to use trainNetwork, the data needs to be in one of the formats described in this doc page: https://uk.mathworks.com/help/deeplearning/ref/trainnetwork.html?s_tid=doc_ta#mw_36a68d96-8505-4b8d-b338-44e1efa9cc5e
So one option would be to apply a transformation to the datastore such that the data is returned as a cell array when calling read on the datastore. Example:
>> ds = spreadsheetDatastore("SeqData.xlsx");
>> ds = transform(ds, @(X){ X{:,1:end-1}', X{:,end}' });
>> data = read(ds)
ans =
1×2 cell array
{8×7081 double} {1×7081 double}
>> net = trainNetwork(ds,layers,opts)
Alternatively, for data that fits in memory and does not require additional processing like custom transformations, you can specify a single sequence as a numeric array. In your case, this can be done by reading the data using readtable and then extracting the first 8 columns into an array of size 8×7081 and extracting the last column into an array of size 1×7081. Example:
Xall = readtable("SeqData.xlsx")
XTrain = Xall{:,end-1}';
YTrain = Xall{:,end}';
net = trainNetwork(XTrain,YTrain,layers,opts)
Note, however, if you have more than one observation, the data needs to be presented as cell arrays of numeric arrays. The doc page linked above should explain all of these details.
Hope this helps.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by