1
我正在測試使用C#進行類分配的NeuronDotNet庫。我有一個非常簡單的控制檯應用程序,用於測試庫中手動提供的一些代碼片段,這個任務的目標是教會程序如何區分可能或可能存在的正方形中的隨機點不在一個也在廣場內的圓圈內。所以基本上,廣場內的哪些點也在圈內。這是我到目前爲止:C#中的神經網絡使用NeuronDotNet
namespace _469_A7
{
class Program
{
static void Main(string[] args)
{
//Initlaize the backpropogation network
LinearLayer inputLayer = new LinearLayer(2);
SigmoidLayer hiddenLayer = new SigmoidLayer(8);
SigmoidLayer outputLayer = new SigmoidLayer(2);
new BackpropagationConnector(inputLayer, hiddenLayer);
new BackpropagationConnector(hiddenLayer, outputLayer);
BackpropagationNetwork network = new BackpropagationNetwork(inputLayer, outputLayer);
//Generate a training set for the ANN
TrainingSet trainingSet = new TrainingSet(2, 2);
//TEST: Generate random set of points and add to training set,
//for testing purposes start with 10 samples;
Point p;
Program program = new Program(); //Used to access randdouble function
Random rand = new Random();
for(int i = 0; i < 10; i++)
{
//These points will be within the circle radius Type A
if(rand.NextDouble() > 0.5)
{
p = new Point(rand.NextDouble(), rand.NextDouble());
trainingSet.Add(new TrainingSample(new double[2] { p.getX(), p.getY() }, new double[2] { 1, 0 }));
continue;
}
//These points will either be on the border or outside the circle Type B
p = new Point(program.randdouble(1.0, 4.0), program.randdouble(1.0, 4.0));
trainingSet.Add(new TrainingSample(new double[2] { p.getX(), p.getY() }, new double[2] { 0, 1 }));
}
//Start network learning
network.Learn(trainingSet, 100);
//Stop network learning
//network.StopLearning();
}
//generates a psuedo-random double between min and max
public double randdouble(double min, double max)
{
Random rand = new Random();
if (min > max)
{
return rand.NextDouble() * (min - max) + max;
}
else
{
return rand.NextDouble() * (max - min) + min;
}
}
}
//Class defines a point in X/Y coordinates
public class Point
{
private double X;
private double Y;
public Point(double xVal, double yVal)
{
this.X = xVal;
this.Y = yVal;
}
public double getX()
{
return X;
}
public double getY()
{
return Y;
}
}
}
這基本上是我需要的所有,我唯一的問題是如何處理輸出?更具體地說,我需要輸出「步長」和「動量」的值,儘管輸出其他信息也不錯。任何有使用NeuronDotNet經驗的人,都會讚賞您的意見。