本文整理汇总了C#中net.adjust2方法的典型用法代码示例。如果您正苦于以下问题:C# net.adjust2方法的具体用法?C# net.adjust2怎么用?C# net.adjust2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net
的用法示例。
在下文中一共展示了net.adjust2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button2_Click
private void button2_Click(object sender, EventArgs e)
{
int num_size=int.Parse(textBox2.Text);
int num_times = int.Parse(textBox1.Text);
net SOM_net = new net(dim, (int)num_size);
double[] data = new double[dim];
double learning_rate = double.Parse(textBox3.Text);
double var_t = double.Parse(textBox4.Text);
double var = double.Parse(textBox6.Text);
if (learning_rate > 1)
{
learning_rate = 1;
textBox3.Text = "1";
}
else if (learning_rate < 0)
{
learning_rate = 0;
textBox3.Text = "0";
}
//迭代
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);
}
}
//.........这里部分代码省略.........