Preparing data for regression using deep neural network
이전 댓글 표시
Hi,
I'm trying to implement a deep neural network for regression with hand-crafted features as the network input. I'm trying to use the Deep Network Designer to achieve this. The network archiecture is similar to the diagram below:
- Each input/feature is a scalar array of length 14751, and there are 9 inputs/features alogether,
- there is one output, again a scalar array of length 14751,
- and there are 4 samples altogether.
- See the data attached.
load data.mat;
inputSize = length(inputs)
[~, numSamples] = size(output) % where each column represents a different sample
exampleInput = inputs{1,1};
size(exampleInput)
Can someone please advise how I can go about preparing the raw data in Datastore format which can be loaded in to Deep Network Designer?
댓글 수: 3
David Ho
2022년 8월 25일
Hello OB,
The best way to import your data into Deep Network Designer by forming two array datastores and combining into a single datastore using the combine function.
For the data you provided, you can do the following:
load data.mat
numFeatures = size(inputs,1);
% All inputs have the same number of timesteps so we
% can get the sizes by looking at the first observation
numTimesteps = size(inputs{1}, 1);
numObservations = size(inputs{1}, 2);
% Reshape the inputs from a cell to an array
arrayInputs = zeros(numFeatures, numTimesteps, numObservations);
for ii = 1:numFeatures
arrayInputs(ii,:,:) = inputs{ii};
end
% Generate ArrayDatastores for the inputs and outputs
adsPredictors = arrayDatastore(arrayInputs, "IterationDimension", 3);
adsResponses = arrayDatastore(output', "IterationDimension", 1);
% Generate a combined datastore for the inputs and outputs together
cds = combine(adsPredictors, adsResponses);
This datastore is suitable for use with a network that has a sequenceInputLayer expecting data with 9 features, and a regressionOutputLayer outputting sequences with one feature.
For more information on creating datastores for Deep Network Desginer, you can refer to the following resources:
https://uk.mathworks.com/help/deeplearning/ug/datastores-for-deep-learning.html
OB
2022년 8월 25일
Milan Bansal
2023년 9월 21일
Change the output size of the last fully connected layer to 1.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
