MATLAB neural networks -
i'm using simple xor input , output data set in order train neural network before attempting harder reason won't work.
may please explain doing wrong please? code:
%user specified values hidden_neurons = 3; epochs = 10000; t_input = [1 1; 1 0; 0 1; 0 0]; t_output = [1; 0; 0; 1]; te_input = [1 1; 1 0; 0 1; 0 0]; net = newff(t_input, t_output, 1); net = init(net); net = train(net, t_input, t_output); net.trainparam.show = 50; net.trainparam.lr = 0.25; net.trainparam.epochs = epochs; net.trainparam.goal = 1e-5; net = train(net, t_input, t_output); out = sim(net, te_input);
this error message:
??? error using ==> network.train @ 145 targets incorrectly sized network. matrix must have 2 columns.
error in ==> smallnn @ 11 net = train(net, t_input, t_output);
you must have samples on columns , not rows (like nn software in world do), change data sets creation lines in:
t_input = [1 1; 1 0; 0 1; 0 0]'; t_output = [1; 0; 0; 1]'; te_input = [1 1; 1 0; 0 1; 0 0]';
now works.
Comments
Post a Comment