为了使用诸如“fminunc()”之类的优化函数,我们将要“展开”所有元素并将它们放入一个长向量中:
thetaVector = [ Theta1(:); Theta2(:); Theta3(:); ]
deltaVector = [ D1(:); D2(:); D3(:) ]
如果Theta1的尺寸是10x11,Theta2是10x11而Theta3是1x11,那么我们可以从“展开”版本中取回原始矩阵,如下所示:
Theta1 = reshape(thetaVector(1:110),10,11)
Theta2 = reshape(thetaVector(111:220),10,11)
Theta3 = reshape(thetaVector(221:231),1,11)
参数展开 学习算法
网友评论