Вы находитесь на странице: 1из 4

TO UPDATE a field: Select the field, click with the right button of the mouse and select: Edit

Field... click OK Keep Microsoft Word Close while editing files as Word locks the files and Neural Lab will not be able to apply the changes. To Insert an image: Insert Tab > Quick Parts > Fields > IncludePicture (i.e. myGraph.emf). Check the option: Mapped Field (\d)( in Spanish Datos No Guardados en el documento.) To insert code: Insert Tab > Quick Parts > Fields >IncludeText (i.e. Train.rtf). Check the option: Text Converter rtf.

Name: Sergio Ledesma Date: Tuesday, June 12, 2012

1. Build Training Set


int numCases = 64; Matrix input; input.CreateRandom(numCases, 2, 0.0, 2.0); // Random values in [0 2] input= floor(input); // Random values in [0 1] Matrix targetTrainSet; targetTrainSet.Create(numCases, 1); //________________________________ Compute the target for each case int row = 0; for(row =0; row < numCases; row++) { if (input[row][0] == 1 && input[row][1] == 1) { targetTrainSet[row][0] = 1; } else { targetTrainSet[row][0] = 0; } } //_______________________________ Create some noise Matrix noise; noise.CreateRandom(numCases, 2, 0.0, 1.0); // Random values in [0 1] //_______________________________ Contaminate the input with noise Matrix inputTrainSet = 0.9 * input+ 0.1 * noise; //_______________________________ Save the training set inputTrainSet .Save(); targetTrainSet.Save();

2. Build Validation Set


int numCases = 128; Matrix input; input.CreateRandom(numCases, 2, 0.0, 2.0); // Random values in [0 2] input= floor(input); // Random values in [0 1] Matrix targetValidSet; targetValidSet.Create(numCases, 1);

Neural Lab http://www.wikipedia.org/wiki/Neural_Lab

//________________________________ Compute the target for each case int row = 0; for(row =0; row < numCases; row++) { if (input[row][0] == 1 && input[row][1] == 1) { targetValidSet[row][0] = 1; } else { targetValidSet[row][0] = 0; } } //_______________________________ Create some noise Matrix noise; noise.CreateRandom(numCases, 2, 0.0, 1.0); // Random values in [0 1] //_______________________________ Contaminate the input with noise Matrix inputValidSet = 0.9 * input+ 0.1 * noise; //_______________________________ Save the validation set inputValidSet .Save(); targetValidSet.Save();

3. Train
//_________________________ Network Setup LayerNet net; net.Create(2, 1, 0, 1); net.SetInputScaler(0, 0.0, 1.0, 1.0); // Input 0: values are from 0.0 to 1.0 net.SetInputScaler(1, 0.0, 1.0, 1.0); // Input 1: values are from 0.0 to 1.0 net.SetOutputScaler(0, 0.0, 1.0, 1.0); // Output 0: values are from 0.0 to 1.0 //________________________ Load and set the training set Matrix inputTrainSet; inputTrainSet.Load(); Matrix targetTrainSet; targetTrainSet.Load(); net.SetTrainingSet(inputTrainSet, targetTrainSet, false); //________________________ Train using Simulated Annealing net.TrainSimAnneal( 100, //Number of Temperatures 100, //Number Iterations 15, //Initial Temperature 0.01, //Final Temperature false, // Is Cooling Schedule Linear? 4, // Number of Cycles 1.0e-5 // Goal (desired mse) ); //_____________________________ Save the trained network net.Save();

Neural Lab http://www.wikipedia.org/wiki/Neural_Lab

4. Check Training
//_______________________ Load the training set Matrix inputTrainSet; inputTrainSet.Load(); Matrix targetTrainSet; targetTrainSet.Load(); //_______________________ Load the ANN LayerNet net; net.Load(); //_______________________ Run Matrix output = net.Run(inputTrainSet, targetTrainSet);

5. Validation
//_______________________ Load the validation set Matrix inputValidSet; inputValidSet.Load(); Matrix targetValidSet; targetValidSet.Load(); //_______________________ Load the ANN LayerNet net; net.Load();

Neural Lab http://www.wikipedia.org/wiki/Neural_Lab

//_______________________ Run Matrix output = net.Run(inputValidSet); //_______________________ Compute the mean squared error double mse = ComputeMse(output, targetValidSet);

Neural Lab http://www.wikipedia.org/wiki/Neural_Lab

Вам также может понравиться