-3

i m doing project on neural network. i want a demo code for AND,OR,X-OR or any SMALL APPLICATION in matlab. thanks

4

1 回答 1

7

这是 XOR 问题的一个简单示例(非线性可分):

input = [0 0; 0 1; 1 0; 1 1]';    %#'
target = [0 1 1 0];               %# target = xor(input(1,:), input(2,:));

%# create ANN: 1 hidden layer with 2 neurons, 
%# and an output layer with a sigmoid transfer function
net = newpr(input, target, 2);
net.divideFcn = '';               %# no data split (training/testing/validation)
net.trainParam.epochs = 50;

net = init(net);
[net,tr] = train(net, input, target);
output = sim(net, input);

[err,cm] = confusion(target,output)

完美的结果:

err =
     0
cm =
     2     0
     0     2

它需要神经网络工具箱

于 2010-08-25T13:55:17.987 回答