Multiple Inputs for Neural Network binary classification (Error Input/Target of different numbers of samples)

4 views (last 30 days)
Hi,
I cannot seem to get the following code to run with 3 matrix inputs (IN_1, IN_2, IN_3) and binary output (0, 1). Each of the input matrix is 30,000 x 2,000 where the row is my input/signal. Below is what I have:
x = 3 x 1 cell of 30,000 x 2000
t = 1 x 30,000
Error using network/train (line 347)
Inputs and targets have different numbers of samples.
[net,tr] = train(net,x,t);
Below is what I have:
% Solve a Pattern Recognition Problem with a Neural Network
% Script generated by Neural Pattern Recognition app
inputData = {IN_1, IN_2, IN_3};
x = inputData';
t = target';
% Choose a Training Function
% For a list of all training functions type: help nntrain
% 'trainlm' is usually fastest.
% 'trainbr' takes longer but may be better for challenging problems.
% 'trainscg' uses less memory. Suitable in low memory situations.
trainFcn = 'traincgf'; % Scaled conjugate gradient backpropagation. traincgf
% Create a Pattern Recognition Network
hiddenLayerSize = 50;
net = patternnet(hiddenLayerSize, trainFcn);
net.numinputs = 3;
net = configure(net,x);
net.inputConnect = [1 1 1; 0 0 0];
% Train the Network
[net,tr] = train(net,x,t);

Accepted Answer

Wookie
Wookie on 22 Mar 2022
inputData = {IN_1'; IN_2'; IN_3'};
x = inputData';
t = target';
trainFcn = 'traincgf';
% Create a Pattern Recognition Network
hiddenLayerSize = 50;
net = patternnet(hiddenLayerSize, trainFcn);
net.numinputs = 3;
net = configure(net,x);
net.inputConnect = [1 1 1; 0 0 0];
% Train the Network
[net,tr] = train(net,x,t);

More Answers (0)

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!