コード例 #1
0
        public override void Learn(List<LearningImagePair> pairs, LearningStyle style)
        {
            List<LearningImage> samples = new List<LearningImage>();
            List<LearningImage> compresses = new List<LearningImage>();
            foreach (var pair in pairs) samples.Add(pair.In);

            if (!_Units[0].IsEnoughToLearn) _Units[0].Learn(samples);

            for (int i = 1; i < _Units.Count; i++)
            {
                Log.Instance.Info("[Process.Learn] " + i + " " + samples.Count);
                _Units[i - 1].ParallelProject(samples, out compresses);

                if (_Units[i].IsEnoughToLearn)
                {
                    // 何もしない
                }
                else if ((style == LearningStyle.Input || style == LearningStyle.InputOutput) && _Units[i].Style == LearningStyle.Input)
                {
                    _Units[i].Learn(compresses);
                }
                else if ((style == LearningStyle.InputOutput) && _Units[i].Style == LearningStyle.InputOutput)
                {
                    List<LearningImagePair> list = new List<LearningImagePair>();
                    for (int j = 0; j < compresses.Count; j++) list.Add(new LearningImagePair(compresses[j], pairs[j].Out));
                    _Units[i].Learn(list);
                }

                samples.Clear();
                GC.Collect();
                samples = compresses;
                compresses = new List<LearningImage>();
            }
        }
コード例 #2
0
    /// <summary>
    /// 从数据库中获取单选题记录
    /// </summary>
    public static LearningStyle GetRadio(int Id)
    {
        SQLHelper dbAccess = new SQLHelper();                   //实例化一个SQLHelper类
        string    sql      = "Select * from [LearningStyle] where Id = @Id";

        SqlParameter[] para = { new SqlParameter("@Id", Id) };       //利用参数para进行动态定义
        SqlDataReader  dr   = dbAccess.GetDRWithPara(sql, para);     //获取查询数据流

        //根据查询得到的数据,对成员赋值
        //数据流中是否有数据
        if (dr.Read())
        {
            LearningStyle r = new LearningStyle();
            r.Id       = int.Parse(dr["Id"].ToString());
            r.question = dr["question"].ToString();
            r.A        = dr["A"].ToString();
            r.B        = dr["B"].ToString();
            //关闭SqlDataReader对象,此时连接同时关闭
            dr.Close();
            return(r);
        }
        else
        {
            dr.Close();
            return(null);
        }
    }
コード例 #3
0
 //通过RadioButtonList控件显示选择题题目
 public static void ShowQuestionRadio(LearningStyle r, RadioButtonList rdoList, Label lbl)
 {
     rdoList.Items[0].Text  = "A." + r.A;
     rdoList.Items[1].Text  = "B." + r.B;
     rdoList.Items[0].Value = "A";
     rdoList.Items[1].Value = "B";
     lbl.Text = r.question;
 }
コード例 #4
0
        public override void Learn(List<LearningImagePair> pairs, LearningStyle style)
        {
            Log.Instance.Info("[DNN.Learn]");
            List<double[]> dataIn = new List<double[]>();
            List<double[]> dataOut = new List<double[]>();
            foreach (var p in pairs)
            {
                dataIn.Add(p.In.Homogenize());
                dataOut.Add(p.Out.Homogenize());
                // 水増し学習
                if (DropoutRate > 0)
                {
                    for (int i = 0; i < DropoutPadding; i++)
                    {
                        dataIn.Add(p.In.DropOut(DropoutRate).Homogenize());
                        dataOut.Add(p.Out.Homogenize());
                    }
                }
            }
            var dataInPrepared = _Teacher.GetLayerInput(dataIn.ToArray());

            for (int i = 0; i < 500; i++)
            {
                _Teacher.RunEpoch(dataInPrepared, dataOut.ToArray());
                _Network.UpdateVisibleWeights();

                double amount = 0;
                int count = 0;
                for(int j = 0; j < dataIn.Count; j += DropoutPadding * 10)	// 適当に省いて評価
                {
                    amount += TestCompute(dataIn[j], dataOut[j]);
                    count++;
                }
                if (i % 10 == 0) Log.Instance.Info("[DNN.Learn]" + i + " " + (amount / count));
                if (amount / count < 0.05) break;
            }
        }
コード例 #5
0
 public virtual void Learn(List<LearningImagePair> pairs, LearningStyle style = LearningStyle.InputOutput)
 {
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["stuId"] != null)
     {
         string stuId         = Session["stuId"].ToString();
         string learningstyle = "";
         stuNews1      = StudentInfoManager.Getstudentnews(stuId);
         learningstyle = stuNews1.learningStyle;
         //判断是否进行过学习风格测试
         if (learningstyle == "")
         {
             r1 = LearningStyleManager.GetRadio(1);                        //获取学习风格测试题
             LearningStyleManager.ShowQuestionRadio(r1, rdolistS1, lblS1); //显示题目
             r2 = LearningStyleManager.GetRadio(2);
             LearningStyleManager.ShowQuestionRadio(r2, rdolistS2, lblS2);
             r3 = LearningStyleManager.GetRadio(3);
             LearningStyleManager.ShowQuestionRadio(r3, rdolistS3, lblS3);
             r4 = LearningStyleManager.GetRadio(4);
             LearningStyleManager.ShowQuestionRadio(r4, rdolistS4, lblS4);
             r5 = LearningStyleManager.GetRadio(5);
             LearningStyleManager.ShowQuestionRadio(r5, rdolistS5, lblS5);
             r6 = LearningStyleManager.GetRadio(6);
             LearningStyleManager.ShowQuestionRadio(r6, rdolistS6, lblS6);
             r7 = LearningStyleManager.GetRadio(7);
             LearningStyleManager.ShowQuestionRadio(r7, rdolistS7, lblS7);
             r8 = LearningStyleManager.GetRadio(8);
             LearningStyleManager.ShowQuestionRadio(r8, rdolistS8, lblS8);
             r9 = LearningStyleManager.GetRadio(9);
             LearningStyleManager.ShowQuestionRadio(r9, rdolistS9, lblS9);
             r10 = LearningStyleManager.GetRadio(10);
             LearningStyleManager.ShowQuestionRadio(r10, rdolistS10, lblS10);
             r11 = LearningStyleManager.GetRadio(11);
             LearningStyleManager.ShowQuestionRadio(r11, rdolistS11, lblS11);
             r12 = LearningStyleManager.GetRadio(12);
             LearningStyleManager.ShowQuestionRadio(r12, rdolistS12, lblS12);
             r13 = LearningStyleManager.GetRadio(13);
             LearningStyleManager.ShowQuestionRadio(r13, rdolistS13, lblS13);
             r14 = LearningStyleManager.GetRadio(14);
             LearningStyleManager.ShowQuestionRadio(r14, rdolistS14, lblS14);
             r15 = LearningStyleManager.GetRadio(15);
             LearningStyleManager.ShowQuestionRadio(r15, rdolistS15, lblS15);
             r16 = LearningStyleManager.GetRadio(16);
             LearningStyleManager.ShowQuestionRadio(r16, rdolistS16, lblS16);
             r17 = LearningStyleManager.GetRadio(17);
             LearningStyleManager.ShowQuestionRadio(r17, rdolistS17, lblS17);
             r18 = LearningStyleManager.GetRadio(18);
             LearningStyleManager.ShowQuestionRadio(r18, rdolistS18, lblS18);
             r19 = LearningStyleManager.GetRadio(19);
             LearningStyleManager.ShowQuestionRadio(r19, rdolistS19, lblS19);
             r20 = LearningStyleManager.GetRadio(20);
             LearningStyleManager.ShowQuestionRadio(r20, rdolistS20, lblS20);
             r21 = LearningStyleManager.GetRadio(21);
             LearningStyleManager.ShowQuestionRadio(r21, rdolistS21, lblS21);
             r22 = LearningStyleManager.GetRadio(22);
             LearningStyleManager.ShowQuestionRadio(r22, rdolistS22, lblS22);
         }
         else
         {
             lblTitle.Visible  = false;
             PanelAll.Visible  = false;
             btnSubmit.Visible = false;
             //Response.Write(string.Format("<script type = 'text/javascript'> alert('{0}'); </script>", "您的学习风格为" + learningstyle + "!"));
             RegisterClientScriptBlock("", string.Format("<script type = 'text/javascript'> alert('{0}'); </script>", "您的学习风格为" + learningstyle + "!"));
         }
     }
     else
     {
         Response.Redirect("Login.aspx");
     }
 }