Clear Filters
Clear Filters

why inputs and targets have diffrent sampels?

2 views (last 30 days)
why do i get this error? iam trying to train a neural network.80%of my data is training data and the rest is test.
Error using network/train (line 340)
Inputs and targets have different numbers of samples.
Error in Untitled3 (line 20)
net= train(net,set',t');
this is my code.
clc
clear all
close all
filename='FIFA2.xlsx';
A =xlsread(filename);
[m,n]=size(A);
T=A(:,1);
data=A(:,(2:end));
[m,n]=size(A);
rows=int32(floor(0.8 * m));
set=A(1:rows,:);
testset=A(rows+1:end,2:n);
t=set(1:rows);
t_test=testset(rows:end);
net= newff(set',t');
y=sim(net,set');
% net.trainParam.epoch=20;
net= train(net,set',t');
y=sim(net,set');
hardlims(y);

Accepted Answer

Greg Heath
Greg Heath on 25 Nov 2018
For I-dimensional "I"nputs and O-dimensional "O"utput targets
After reading in inputs and targets
ALWAYS CHECK THE DIMENSIONS !!!
[ I Ni ] = size(input)
[ O Nt ] = size(target)
if Nt == Ni
N = Ni
else
error
end
Hope this helps
Thank you for formally accepting my answer
Greg

More Answers (0)

Categories

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

Community Treasure Hunt

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

Start Hunting!