neural network input error
조회 수: 3 (최근 30일)
이전 댓글 표시
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개)
Tejas
2024년 11월 13일 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);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!