Neural network using MATLAB

亡梦爱人 提交于 2019-12-05 06:10:01

问题


I have a training set that has input and outputs in this way:

Input:
0.832 64.643
0.818 78.843
1.776 45.049
0.597 88.302
1.412 63.458
1.468 49.535
1.985 33.387
2.073 30.279
1.431 55.231
1.116 68.521
1.617 44.362
2.159 66.512

Output:
0 0 1
0 0 1
0 1 0
0 0 1
0 0 1
1 0 0
0 0 1
1 0 0
1 0 0
0 0 1
0 0 1
0 1 0
1 0 0
1 0 0
0 1 0
0 1 0

I need to implement one linear layer neural network that can represent the data set best in MATLAB. What would be the algorithm to do it in MATLAB?

The target output is "1 for a particular class that the corresponding input belongs to and "0 for the remaining 2 outputs.


回答1:


Consider this example of training a feed-forward ANN of one hidden layer (with 3 nodes). Since your data seems to have more output points than input, I'm using a demo dataset, but the idea is the same:

%# load sample data
laod simpleclass_dataset
input = simpleclassInputs;          %# 2x1000, 2-dimensional points
output = simpleclassTargets;        %# 4x1000, 4 classes

%# split data into training/testing sets
trainInd = 1:500;
testInd = 501:1000;

%# create ANN and initialize network weights
net = newpr(input, output, 3);
net = init(net);
net.trainParam.epochs = 25;        %# max number of iterations

%# learn net weights from training data
net = train(net, input(:,trainInd), output(:,trainInd));

%# predict output of net on testing data
pred = sim(net, input(:,testInd));

%# classification confusion matrix
[err,cm] = confusion(output(:,testInd), pred);

The output is:

err =
     0.075075
cm =
    81     0     0     0
     0    82     0     0
     9     0    52    16
     0     0     0    93

Obviously you will need access to the Neural Network Toolbox.



来源:https://stackoverflow.com/questions/3429290/neural-network-using-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!