In Deep Learning Toolbox, what input layer should I use for simple dataframe-type input?
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(3 个)
Srivardhan Gadila
2020-4-14
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
2020-4-14
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
2021-12-7
编辑:Yomna Genina
2021-12-7
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!