Пример #1
0
 /// <summary>
 /// 获取权重(先验概率)
 /// </summary>
 /// <param name="key"></param>
 /// <param name="ID">神经元编号</param>
 /// <returns></returns>
 public double GetW(string key, int ID)
 {
     if (!W.ContainsKey(key))
     {
         W.Add(key, new Dictionary <int, WMatrix>());
     }
     if (!W[key].ContainsKey(ID))
     {
         WMatrix w = new WMatrix();
         w.ID = ID;
         w.W  = Convert.ToDouble(ID) / 10;
         W[key].Add(ID, w);
     }
     return(W[key][ID].W);
 }
Пример #2
0
 /// <summary>
 /// 设置权重
 /// </summary>
 /// <param name="key"></param>
 /// <param name="ID"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public void SetW(string key, int ID, double value)
 {
     if (!W.ContainsKey(key))
     {
         W.Add(key, new Dictionary <int, WMatrix>());
     }
     if (!W[key].ContainsKey(ID))
     {
         WMatrix w = new WMatrix();
         w.ID = ID;
         w.W  = value;
         W[key].Add(ID, w);
     }
     W[key][ID].W = value;
 }
Пример #3
0
 /// <summary>
 /// 添加词频
 /// </summary>
 /// <param name="key"></param>
 /// <param name="idCount">神经元个数</param>
 /// <param name="value"></param>
 public void Add(string key, int idCount, int value)
 {
     if (!Freq.ContainsKey(key))
     {
         Freq.Add(key, 1);
     }
     if (!W.ContainsKey(key))
     {
         W.Add(key, new Dictionary <int, WMatrix>());
         for (int id = 1; id <= idCount; id++)
         {
             WMatrix w = new WMatrix();
             w.ID = id;
             w.W  = Convert.ToDouble(id) / 10;
             W[key].Add(id, w);
         }
     }
     Freq[key] += value;
     total     += value;
 }