| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 327 人关注过本帖
标题:RBF用OLS训练权值的代码 求解释代码!!!
只看楼主 加入收藏
hsh0756
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-4-29
收藏
 问题点数:0 回复次数:0 
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-04-29 13:51
快速回复:RBF用OLS训练权值的代码 求解释代码!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036216 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved