neural network input error

3 visualizaciones (últimos 30 días)
Junfan Zhou
Junfan Zhou el 30 de Abr. de 2018
Respondida: Tejas el 13 de Nov. de 2024 a las 6:53
Hi friends,
I get the following error while trying to use neural network toolbox in matlab. I am new to its use, thereby any help would be crucial.
Here are my codes:
if true
% code
function NET = trainnet(net,IMGDB);
net.trainFcn = 'trainscg';
net.trainParam.lr = 0.4;
net.trainParam.epochs = 400;
net.trainParam.show = 10;
net.trainParam.goal = 1e-3;
T{1,1} = cell2mat(IMGDB(2,:));
P{1,1} = cell2mat(IMGDB(2,:));
net = train(net,P,T);
save net net
NET = net;
end
I get the following error :
if true
% code
错误使用 network/train (line 340)
Input data size does not match net.inputs{1}.size.
end
Thanks!
  1 comentario
Kaiwen
Kaiwen el 9 de Feb. de 2023
I meets the same problem.Have you solved the problem?

Iniciar sesión para comentar.

Respuestas (1)

Tejas
Tejas el 13 de Nov. de 2024 a las 6:53
Hello Junfan,
The error indicates a mismatch between the size of the input data and what the input layer of the neural network expects. To fix this, ensure that the input data matches the expected size of the neural network's input layer.
Check the expected input size before passing 'net' to the 'triannet' function, using the below code snippet. For more information on properties of 'net' object, refer to this documentation: https://www.mathworks.com/help/deeplearning/ref/network.html#:~:text=net.inputs,input%20i.
net.inputs{1}.size;
If the input layer size is correct, adjust the input data to match this size. Conversely, if the input layer size is not as desired, adjust the input layer to fit the input data.
Here is an example demonstrating how to modify the input layer size:
  • Generate sample data and create a sample neural network.
numFeatures = 3;
numSamples = 100;
P = rand(numFeatures, numSamples);
T = rand(1, numSamples);
hiddenLayerSize = 10;
net = feedforwardnet(hiddenLayerSize);
  • Adjust the size of the input layer accordingly.
net.inputs{1}.size = numFeatures;
NET = train(net, P, T);

Categorías

Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by