How can I load 2 features XTrain and YTrain to SequenceInputyer in Deep learning toolbox?
3 次查看(过去 30 天)
显示 更早的评论
I have a two-feature dataset. The type of XTrain is 2x6000 double, while the type of YTrain is also 2x6000 double. I have transform them into arrayDatastore by
adsXTrain=arrayDatastore(XTrain,"ReadSize",2,"OutputType","same");
adsYTrain=arrayDatastore(YTrain,"ReadSize",2,"OutputType","same");
Then, I combine these two datasets by
cdsTrain=combine(adsXTrain,adsYTrain);
Unfortunately, when I import cdsTrain in Deep Network Designer as Datastore, it shows 2x12000 double not two columns of 2x6000 double
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1037210/image.png)
If so, Deep Network Designer can't idenfy the dataset as XTrain and YTrain during training.
0 个评论
回答(1 个)
Ben
2022-6-20
Using "OutputType" as "cell" should help this - e.g. you can do the following at the command line:
% Create fake data,
% I am assuming you have 6000 observations of 2 features.
x = randn(2,6000);
% Create arrayDatastore, use cell outputs, and iteration dimension 2.
% Note - no need to set ReadSize,
% trainNetwork and trainingOptions MiniBatchSize option will handle that.
ds = arrayDatastore(x,"OutputType","cell","IterationDimension",2);
% For this example I just duplicate x for the target data.
cds = combine(ds,ds);
testOutput = cds.read % should be a 1x2 cell where each cell contains a 2x1 vector.
% dummy network and training
layers = [featureInputLayer(2)
fullyConnectedLayer(2)
regressionLayer];
opts = trainingOptions("adam");
net = trainNetwork(cds,layers,opts);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!