2015-10-13 162 views
0
sampleInput = 

    2.1053 -4.8512 4.6223 0.9665 1.0000 


hiddenWeights = 

    -0.6342 -0.2089 0.4533 -0.6182 -0.3663 
    -0.9465 -1.0770 -0.2668 0.7077 -1.1656 
    0.0936 -0.2853 -0.1408 0.6193 -0.5481 
    1.4253 0.3770 -0.6710 0.1069 0.0310 

我希望結果是隱藏的權重,每列等於上一列* 2.1053。所以hiddenWeights的第一列是:將矩陣中的每列乘以向量中的列乘以

2.1053 * -0.6342 
2.1053 * -0.9464 
etc. 
+0

所以做了什麼,我建議幫助? – rayryeng

+0

嗨,我們的答案也有幫助嗎? [如何接受一個答案的工作?](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) – rayryeng

回答

7

聽起來像是bsxfun工作:

out = bsxfun(@times, hiddenWeights, sampleInput); 

這裏,sampleInput會多次出現在hiddenWeights行復制其行,將發生用hiddenWeights與該新矩陣進行元素乘法運算。結果將是hiddenWeights的每一列將與sampleInput中的相應列相乘,並且將成爲您的願望。

+1

我要問OP他們的意思,但這種解釋它;) –

1

另一種可能是把sampleInput成一個對角矩陣,並應用矩陣乘法:

result = hiddenWeights*diag(sampleInput); 
+0

這也行! – rayryeng