2013-06-05 72 views
0

我想實現一個這樣工作的模型: 它得到3個輸入,例如 - 1,2,3 ,它給出1個輸出 - 0到1之間的數字(包括0和1)。 該模型是一個前饋網絡 - 首先,它「訓練」 - 獲取輸入和結果,然後根據他的訓練,只給出輸入的結果,例如: 有一次他得到1 ,2,3和結果:0, 第二次他得到了2,3,4和結果:0, 第三次他得到了3,4,5和結果:1.第二次他得到了4,5,6但是 但是沒有結果 - 所以根據他的知識和算法,他會給出一個結果,讓我們說:0.45。在Matlab中創建一個feedforwardnet模型

我的問題是,輸入的向量大小和結果向量的大小必須相等,所以當我只需要1個結果時,結果的向量必須包含3個元素 - 所以我將所有元素相同,意思是:它獲得[1 1 1]或[0 0 0](我希望它不會破壞網絡)。 無論如何,這是我的模型的代碼 - 我是否實現了它?因爲我不知道......

% x1 is the input in the 1st case, x2 is the input in the 2nd case... 
% t1 is the result in the 1st case, t2 is the result in the 2nd case... 
net=feedforwardnet(1); 
x1=[1 2 3]; 
t1=[0 0 0]; 
x2=[2 3 4]; 
t2=[0 0 0]; 
x3=[3 4 5]; 
t3=[1 1 1]; 
x4=[4 5 6]; 
net=train(net,x1,t1); 
net=train(net,x2,t2); 
net=train(net,x3,t3); 
t4=net(x4) 

回答

1

不,應該接受培訓,一個曾經和多情況下應該放在只有一個矩陣

the right program should be as follows: 
x = [x1', x2', x3']; 
t = [0 0 1]; 
net = train(net, x, t); 
t4 = net(x4)