• 大小: 579KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-14
  • 语言: C#
  • 标签: C#  MATLAB  

资源简介

对于想实现C#调用神经网络工具箱的开发者提供很好的思路

资源截图

代码片段和文件信息

using System;
using System.IO;
using System.Text;
namespace BpANNet
{
    public class BpNet
    {
        public int inNum;//输入节点数
        int hideNum;//隐层节点数
        public int outNum;//输出层节点数
        public int sampleNum;//样本总数

        Random R;
        double[] x;//输入节点的输入数据
        double[] x1;//隐层节点的输出
        double[] x2;//输出节点的输出

        double[] o1;//隐层的输入
        double[] o2;//输出层的输入
        public double[] w;//权值矩阵w
        public double[] v;//权值矩阵V
        public double[] dw;//权值矩阵w
        public double[] dv;//权值矩阵V


        public double rate;//学习率
        public double[] b1;//隐层阈值矩阵
        public double[] b2;//输出层阈值矩阵
        public double[] db1;//隐层阈值矩阵
        public double[] db2;//输出层阈值矩阵

        double[] pp;//输出层的误差
        double[] qq;//隐层的误差
        double[] yd;//输出层的教师数据
        public double e;//均方误差
        double in_rate;//归一化比例系数

        /// 
        /// 计算隐藏节点数
        /// 

        /// 表示输入的节点数
        /// 表示输出的节点数
        /// 
        public int computeHideNum(int m int n)
        {
            double s = Math.Sqrt(0.43 * m * n + 0.12 * n * n + 2.54 * m + 0.77 * n + 0.35) + 0.51;
            int ss = Convert.ToInt32(s);
            return ((s - (double)ss) > 0.5) ? ss + 1 : ss;

        }

        /// 
        /// Bp神经网络函数
        /// 

        /// 表示输入数组
        /// 表示输出数组
        public BpNet(double[] p double[] t)
        {

            // 构造函数逻辑
            R = new Random(32); //加了一个参数,使产生的伪随机序列相同

            this.inNum = p.GetLength(1); //数组第二维大小为 输入节点数
            this.outNum = t.GetLength(1); //输出节点数
            this.hideNum = computeHideNum(inNum outNum); //隐藏节点数,不知其原理
            //      this.hideNum=18;
            this.sampleNum = p.GetLength(0); //数组第一维大小 为

            Console.WriteLine(“输入节点数目: “ + inNum);
            Console.WriteLine(“隐层节点数目:“ + hideNum);
            Console.WriteLine(“输出层节点数目:“ + outNum);

            Console.ReadLine();

            x = new double[inNum];
            x1 = new double[hideNum];
            x2 = new double[outNum];

            o1 = new double[hideNum];
            o2 = new double[outNum];

            w = new double[inNum hideNum];
            v = new double[hideNum outNum];
            dw = new double[inNum hideNum];
            dv = new double[hideNum outNum];

            b1 = new double[hideNum];
            b2 = new double[outNum];
            db1 = new double[hideNum];
            db2 = new double[outNum];

            pp = new double[hideNum];
            qq = new double[outNum];
            yd = new double[outNum];

            //初始化w
            for (int i = 0; i < inNum; i++)
            {
                for (int j = 0; j < hideNum; j++)
                {
                    w[i j] = (R.Next

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      13970  2014-12-26 10:44  WindowsFormsApplication1\BpANNet.cs

     文件         89  2014-12-26 15:47  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\b1.txt

     文件         19  2014-12-26 15:47  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\b2.txt

     文件      98304  2014-12-22 22:40  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\bnpp_net.dll

     文件     200704  2014-12-22 22:40  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\bnpp_net_1.dll

     文件     200704  2014-12-22 22:40  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\bnpp_net_noargs.dll

     文件       3272  2015-01-05 21:51  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\BPNN.m

     文件       8704  2014-12-29 12:50  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\Interop.MLApp.dll

     文件     167936  2014-12-22 22:40  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\ManagedCPPAPI.netmodule

     文件      90112  2014-12-22 22:40  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\MWArray.dll

     文件         14  2014-12-26 15:47  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\para.txt

     文件         97  2014-12-26 15:47  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\v.txt

     文件        556  2014-12-26 15:47  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\w.txt

     文件      15360  2015-01-06 22:30  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe

     文件      40448  2015-01-06 22:30  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb

     文件      11600  2015-01-06 22:30  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe

     文件        490  2010-03-17 22:39  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest

     文件      13970  2014-12-26 10:48  WindowsFormsApplication1\WindowsFormsApplication1\BpANNet.cs

     文件       2897  2015-01-06 22:30  WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs

     文件       2603  2014-12-26 12:51  WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs

     文件       5817  2014-12-26 12:51  WindowsFormsApplication1\WindowsFormsApplication1\Form1.resx

     文件      98304  2014-12-22 22:40  WindowsFormsApplication1\WindowsFormsApplication1\MWArray.dll

     文件       8662  2014-12-23 09:53  WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6458  2015-01-06 22:30  WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       4096  2014-12-22 22:40  WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\Interop.Bnppprj.dll

     文件       8704  2014-12-29 12:50  WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\Interop.MLApp.dll

     文件      16896  2014-12-22 22:40  WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\Interop.MWComUtil.dll

     文件       4166  2015-01-06 22:30  WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt

     文件        975  2014-12-26 12:51  WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache

     文件        886  2014-12-30 09:54  WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.csproj.ResolveComReference.cache

............此处省略26个文件信息

评论

共有 条评论