RBF用OLS算法训练权值的代码 求解释代码

• 问题

•   public void QR_Algorithm(List<double> temp_result, List<List<double>> Amatrix, List<double> Bmatrix, int MatrixRow, int MatrixColumn)
{
int k = 0, l = 1;   //序号k以下的元素,才做处理,l表处理的cloumn,s为序号k以下(包含)到最後元素的平方和开根号
int i, j;
bool CheckIf = true;
double s, temp_s = 0.0;
double r, temp_r = 0.0;

List<double> DiagonalofRMatrix = new List<double>();  //double *DiagonalofRMatrix;
//DiagonalofRMatrix存放R榘阵的对角线值
DiagonalofRMatrix = CMatrix.Vector(MatrixColumn+1, 0.0);

while (l <= MatrixColumn && CheckIf == true)   // MatrixColumn隐藏神经元
{
k = k + 1;
if (k == MatrixRow)   //MatrixRow样本数
{
DiagonalofRMatrix[l] = Amatrix[k][l];  //Amatrix[k][l]表示样本k在隐藏神经元l中的高斯函数值
CheckIf = false;
continue;   //跳出整个l回圈
}

temp_s = 0.0; //temp_s要归零
for (i = k; i <= MatrixRow; i++)
temp_s = temp_s + Amatrix[i][l] *Amatrix[i][l];  //所有样本对隐藏神经元的高斯函数值的平方
//temp_s存放元素平方和

s = Math.Sqrt(temp_s);

if (s == 0.0)
{
DiagonalofRMatrix[l] = 0.0;
continue;   //跳至下个l
}

double t = Amatrix[k][l];
if (t >= 0) //t与s要异号
{
temp_r = s * (s + t);
r = 1 / Math.Sqrt(temp_r);
}
else
{
temp_r = -s * (-s + (-t));
r = 1 / Math.Sqrt(temp_r);
}

DiagonalofRMatrix[l] = -s;
Amatrix[k][k] = r * (s + t);
for (i = k + 1; i <= MatrixRow; i++)
{
Amatrix[i][k] = r * Amatrix[i][l];
}

for (j = l + 1; j <= MatrixColumn; j++)
{
t = 0;
for (i = k; i <= MatrixRow; i++)
t = t + Amatrix[i][k] * Amatrix[i][j];
for (i = k; i <= MatrixRow; i++)
Amatrix[i][j] = Amatrix[i][j] - t * Amatrix[i][k];
}
l++;
}

QR_leastsquare(temp_result, Amatrix, Bmatrix, DiagonalofRMatrix, MatrixRow, MatrixColumn);

CMatrix.FreeVector(DiagonalofRMatrix);
}

主要是while循环中 是怎么实现正交的

2011年4月29日 5:36

全部回复

• 第三方的类库请在相关的论坛寻求技术支持,例如:
http://sourceforge.net/projects/cmatrix/support

Leo Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

-------------------------------------------------
This response contains links reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you.
Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
2011年5月4日 8:16