In Deep Learning Toolbox, what input layer should I use for simple dataframe-type input?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
In Deep Learning Toolbox, we can use imageInputLayer() and imageDatastore() for image-type input.
How about the simplest type of input: the dataframe (say an array)?
Which input layer should we use? Should we use datastore() for this type of input?
I don't see many tutorial about this type of input and I got error for the below code. Each of my data point contains 2 features (i.e. size 2x1x1), but when Matlab read the data store, it can only read 1 feature (i.e. 1x1x1).
Failed code
Error message: The training images are of size 1x1x1 but the input layer expects images of size 2x1x1.
data=[ ...
-0.4 -0.8; ...
-1.4 -1.0; ...
-1.5 -1.7; ...
-2.3 -2.0; ...
-1.2 -1.1; ...
];
csvwrite('data.csv',data);
ds_features = datastore('data.csv');
layers = [
imageInputLayer([2 1 1],'Name','in')
fullyConnectedLayer(10,'Name','fc1')
softmaxLayer('Name','sm1')
classificationLayer('Name','cf1')];
lgraph = layerGraph(layers);
options = trainingOptions('sgdm', ...
'MaxEpochs',4, ...
'Verbose',false, ...
'Plots','training-progress');
net = trainNetwork(ds_features,layers,options);
0 Kommentare
Antworten (3)
Srivardhan Gadila
am 14 Apr. 2020
In the above question I see that you haven't provided any target data(classification labels) for training the network.
To use an image datastore as a source of training data, use the imds argument of trainNetwork. To use all other types of datastore as a source of training data, use the ds argument of trainNetwork. To be a valid input for training or validation, the read function of a datastore (with the exception of ImageDatastore) must return data as either a cell array or a table.
For networks with a single input, the table or cell array returned by the datastore must have two columns. The first column of data represents inputs to the network and the second column of data represents responses. Each row of data represents a separate observation.
In case of input size 2x1 & a table, it should be something like below:
>>>data = read(ds)
data =
4×2 table
input response
______________ ________
{2×1 double} 7
{2×1 double} 7
{2×1 double} 9
{2×1 double} 9
Sean de Wolski
am 14 Apr. 2020
I don't think deep learning is the right approach if your input data has two points. Consider using a standard machine learning technique and the classification learner app.
Yomna Genina
am 7 Dez. 2021
Bearbeitet: Yomna Genina
am 7 Dez. 2021
Starting R2020b, you could use featureInputLayer for a dataset containing numeric features.
See this example for more details: https://www.mathworks.com/help/deeplearning/ug/train-network-on-data-set-of-numeric-features.html
0 Kommentare
Siehe auch
Kategorien
Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!