本文整理汇总了C#中net.win_count方法的典型用法代码示例。如果您正苦于以下问题:C# net.win_count方法的具体用法?C# net.win_count怎么用?C# net.win_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net
的用法示例。
在下文中一共展示了net.win_count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button2_Click
//.........这里部分代码省略.........
}
//迭代
for (int i = 0; i < num_times; i++)
{
//先跑一遍資料集
for (int j = 0; j < dataset.Count; j++)
{
for (int k = 0; k < dim; k++)
data[k] = dataset[i][k];
SOM_net.calculate(data);
SOM_net.adjust2(learning_rate * (1 - i / (double)num_times),i + 1, var, var_t);
}
}
//打亂資料
Random rand = new Random();
int index;
double[] temp;
for (int i = 0; i < dataset.Count; i++)
{
index = rand.Next(0, dataset.Count - 1);
temp = dataset[i];
dataset[i] = dataset[index];
dataset[index] = temp;
}
//畫出結果
if (dim == 2)
{
Bitmap windowshow = new Bitmap(pictureBox1.Size.Width, pictureBox1.Size.Height);
windowshow = window.Clone() as Bitmap;
Graphics graph = Graphics.FromImage(windowshow);
graph.PageUnit = GraphicsUnit.Pixel;
graph.TranslateTransform((int)half_height, (int)half_width);
SolidBrush mybrush = new SolidBrush(Color.Red);
//畫出神經元連線
Point begin = new Point(0, 0);
Point end = new Point(0, 0);
Pen mypen = new Pen(Color.Blue, 2);
for (int i = 0; i < SOM_net.net_size; i++)
for (int j = 0; j < SOM_net.net_size; j++)
{
begin.X = (int)(half_width * SOM_net.cell[i, j].weight[0] / max_dis);
begin.Y = (int)(-1*half_height * SOM_net.cell[i, j].weight[1] / max_dis);
if (j > 0)//左
{
end.X = (int)(half_width * SOM_net.cell[i, j - 1].weight[0] / max_dis);
end.Y = (int)(-1 * half_height * SOM_net.cell[i, j - 1].weight[1] / max_dis);
graph.DrawLine(mypen, begin, end);
}
if (j + 1 < SOM_net.net_size)//右
{
end.X = (int)(half_width * SOM_net.cell[i, j + 1].weight[0] / max_dis);
end.Y = (int)(-1 * half_height * SOM_net.cell[i, j + 1].weight[1] / max_dis);
graph.DrawLine(mypen, begin, end);
}
if (i > 0)//上
{
end.X = (int)(half_width * SOM_net.cell[i - 1, j].weight[0] / max_dis);
end.Y = (int)(-1 * half_height * SOM_net.cell[i - 1, j].weight[1] / max_dis);
graph.DrawLine(mypen, begin, end);
}
if (i + 1 < SOM_net.net_size)//下
{
end.X = (int)(half_width * SOM_net.cell[i + 1, j].weight[0] / max_dis);
end.Y = (int)(-1 * half_height * SOM_net.cell[i + 1, j].weight[1] / max_dis);
graph.DrawLine(mypen, begin, end);
}
}
//畫出神經元
for (int i = 0; i < SOM_net.net_size; i++)
{
for (int j = 0; j < SOM_net.net_size; j++)
{
Rectangle dot = new Rectangle((int)(half_width * SOM_net.cell[i, j].weight[0] / max_dis),(int)(-1 * half_height * SOM_net.cell[i, j].weight[1] / max_dis),6, 6);
graph.FillEllipse(mybrush, dot);
}
}
pictureBox1.Image = windowshow;
graph.Dispose();
}
//計算得勝數
SOM_net.win_clear();
for (int i = 0; i < dataset.Count(); i++)
{
for (int j = 0; j < dim; j++)
data[j] = dataset[i][j];
SOM_net.win_count(data);
}
//顯示得勝數
textBox5.Text += "winner count" + Environment.NewLine;
for (int i = 0; i < SOM_net.net_size; i++)
for (int j = 0; j < SOM_net.net_size; j++)
textBox5.Text += "No" + SOM_net.cell[i, j].NO + ":\t" + SOM_net.cell[i, j].winner + Environment.NewLine;
}