// The constructor obtains the state information. public locatePointThread( BaseTypes.viewport Vprt,Rectangle ScanArea,Bitmap Bmp,int AcceptanceThreshold,int radius, NeuralNetwork aan, locatePointThreadCallback callbackDelegate) { this.vprt = Vprt; this.scanArea = ScanArea; this.bmp = Bmp; this.acceptanceThreshold = AcceptanceThreshold; this.Radius=radius; this.Ann=aan; callback = callbackDelegate; }
//train single neural network with given training set and parameters private void trainNetwork(ArrayList trainingSet, ref NeuralNetwork Ann, double trainingRate, int trainingIterationsCount) { //set answers double[] answerYes=new double[4]{1,1,1,1}; double[] answerNo=new double[4]{0,0,0,0}; int Iteration; int index; Random R = new Random(); for (Iteration=0; Iteration<trainingIterationsCount; Iteration++) { //random-pick training set index index=(int)Math.Round((R.NextDouble() * ((32-1)-1))); //get tranining sample from training set double[] a = (double[])trainingSet[index]; //train network with set if (index>15) Ann.TrainNetwork(answerYes,a,trainingRate); else Ann.TrainNetwork(answerNo,a,trainingRate); } }
//train point in certain viewport (generate training set and train neural network) private void trainPoint(BaseTypes.viewport vprt,Bitmap bmp, ref NeuralNetwork Ann, int hls, int ovs, int hlc, iActivationFunction af, double tr, int tic, int miw, int maw) { trainingSet=new ArrayList(); switch (vprt) { case BaseTypes.viewport.XY: { trainingSet=(ArrayList)(generateTrainingSet(BaseTypes.viewport.XY,bmp).Clone()); //create new neural network object Ann = new NeuralNetwork((int)Math.Pow((xyRadius*2),2),hls, ovs,hlc,af); //initialize weights Ann.DrawWeights(miw, maw); //train network trainNetwork(trainingSet,ref Ann,tr,tic); break; } case BaseTypes.viewport.XZ: { trainingSet=(ArrayList)(generateTrainingSet(BaseTypes.viewport.XZ,bmp).Clone()); //create new neural network object Ann = new NeuralNetwork((int)Math.Pow((xzRadius*2),2),hls, ovs,hlc,af); //initialize weights Ann.DrawWeights(miw, maw); //train network trainNetwork(trainingSet,ref Ann,tr,tic); break; } case BaseTypes.viewport.YZ: { trainingSet=(ArrayList)(generateTrainingSet(BaseTypes.viewport.YZ,bmp).Clone()); //create new neural network object Ann = new NeuralNetwork((int)Math.Pow((yzRadius*2),2),hls, ovs,hlc,af); //initialize weights Ann.DrawWeights(miw, maw); //train network trainNetwork(trainingSet,ref Ann,tr,tic); break; } } }
public trackingPoint(string name, trackingPoint tp, Color col) { this.pColor = tp.pColor; this.xyAnn = tp.xyAnn; this.xyCoordX=tp.xyCoordX; this.xyCoordY=tp.XyCoordY; this.xyRadius=tp.xyRadius; this.xyTrackPointImage=tp.xyTrackPointImage; this.xzAnn = tp.xzAnn; this.xzCoordX=tp.xzCoordX; this.xzCoordZ=tp.xzCoordZ; this.xzRadius=tp.xzRadius; this.xzTrackPointImage=tp.xzTrackPointImage; this.yzAnn = tp.yzAnn; this.yzCoordZ=tp.yzCoordZ; this.yzCoordY=tp.yzCoordY; this.yzRadius=tp.yzRadius; this.yzTrackPointImage=tp.yzTrackPointImage; this.calculateWorldCoords(); this.pColor=col; this.pName=name; }