Questions from a beginner about Machine Learning
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I must carry out a project whose purpose is to calculate the coefficients of a profile with AI. To make a long story short, I have an array size 120*7.
The first 5 values of the line are the parameters (Reynolds number, etc.) to calculate the coefficients and the next 2 values are the lift and drag coefficient. I only have 120 lines for now but more will arrive later.
I have formatted my data as follows :
XTrain =
120×1 cell array
{5×1 double}
{5×1 double}
...
YTrain =
120×1 cell array
{2×1 double}
...
Is this the right format ?
Then I created this network by copying examples from the site
net = network( ...
1, ... % numInputs, number of inputs,
2, ... % numLayers, number of layers
[1;0], ... % biasConnect, numLayers-by-1 Boolean vector,
[1;0], ... % inputConnect, numLayers-by-numInputs Boolean matrix,
[0 0; 1 0], ... % layerConnect, numLayers-by-numLayers Boolean matrix
[0 1] ... % outputConnect, 1-by-numLayers Boolean vector
);
% number of hidden layer neurons
net.layers{1}.size = 4;
% hidden layer transfer function
net.layers{1}.transferFcn = 'logsig';
net = configure(net,XTrain,YTrain);
view(net);
(This network is probably not the best for my problem but it's a test)
I get this error about the dimensions of the input. Yet while searching on the internet, I have the impression that the dimension of the input is 1.
Error using network/configure (line 134)
The numbers of input signals and networks inputs do not match.
Can you please help me with that ?
Thanks !
0 个评论
回答(1 个)
Rushil
2025-5-8
Hello
MATLAB’s feedforward neural networks expect the input data as a matrix of size [numFeatures × numSamples] and the output (target) data as [numOutputs × numSamples].
For this scenario, the input data should be arranged as a matrix with 5 rows and 120 columns (representing 5 features for each of the 120 samples), and the output data should be a matrix with 2 rows and 120 columns (representing 2 outputs per sample), rather than using cell arrays.
An approach to resolve the issue is to reshape the data into matrices and use the “feedforwardnet” function for simplicity. Refer to the sample code snippet below:
XTrainMat = cell2mat(XTrain'); % 5×120
YTrainMat = cell2mat(YTrain'); % 2x120
net = feedforwardnet(4);
net.layers{1}.transferFcn = 'logsig';
net = train(net, XTrainMat, YTrainMat);
view(net);
To know more about the “feedforwardnet” function, visit the link below:
Hope it helps
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!