func main() { const num_layers = 3 const num_neurons_hidden = 96 const desired_error = 0.001 train_data := fann.ReadTrainFromFile("../../datasets/robot.train") test_data := fann.ReadTrainFromFile("../../datasets/robot.test") var momentum float32 for momentum = 0.0; momentum < 0.7; momentum += 0.1 { fmt.Printf("============= momentum = %f =============\n", momentum) ann := fann.CreateStandart(num_layers, []uint32{train_data.GetNumInput(), num_neurons_hidden, train_data.GetNumOutput()}) ann.SetTrainingAlgorithm(fann.TRAIN_INCREMENTAL) ann.SetLearningMomentum(momentum) ann.TrainOnData(train_data, 2000, 500, desired_error) fmt.Printf("MSE error on train data: %f\n", ann.TestData(train_data)) fmt.Printf("MSE error on test data : %f\n", ann.TestData(test_data)) ann.Destroy() } train_data.Destroy() test_data.Destroy() }
func main() { const numLayers = 3 const numNeuronsHidden = 32 const desiredError = 0.0001 const maxEpochs = 300 const epochsBetweenReports = 10 fmt.Println("Creating network.") trainData := fann.ReadTrainFromFile("datasets/mushroom.train") ann := fann.CreateStandart(numLayers, []uint32{trainData.GetNumInput(), numNeuronsHidden, 1}) fmt.Println("Training network.") ann.SetActivationFunctionHidden(fann.SIGMOID_SYMMETRIC_STEPWISE) ann.SetActivationFunctionOutput(fann.SIGMOID_SYMMETRIC) ann.TrainOnData(trainData, maxEpochs, epochsBetweenReports, desiredError) fmt.Println("Testing network") testData := fann.ReadTrainFromFile("datasets/mushroom.test") ann.ResetMSE() var i uint32 for i = 0; i < testData.Lenght(); i++ { ann.Test(testData.GetInput(i), testData.GetOutput(i)) } fmt.Printf("MSE error on test data: %f\n", ann.GetMSE()) fmt.Println("Saving network.") ann.Save("mushroom_float.net") fmt.Println("Cleaning up.") trainData.Destroy() testData.Destroy() ann.Destroy() }
func main() { const num_layers = 3 const num_neurons_hidden = 30 const desired_error = 0.001 fmt.Println("Creating network.") train_data := fann.ReadTrainFromFile("../../datasets/robot.train") ann := fann.CreateStandart(num_layers, []uint32{train_data.GetNumInput(), num_neurons_hidden, train_data.GetNumOutput()}) fmt.Println("Training network.") ann.SetTrainingAlgorithm(fann.TRAIN_INCREMENTAL) ann.SetLearningMomentum(0.4) ann.TrainOnData(train_data, 3000, 10, desired_error) fmt.Println("Testing network") test_data := fann.ReadTrainFromFile("../../datasets/robot.test") ann.ResetMSE() var i uint32 for i = 0; i < test_data.Lenght(); i++ { ann.Test(test_data.GetInput(i), test_data.GetOutput(i)) } fmt.Printf("MSE error on test data: %f\n", ann.GetMSE()) fmt.Println("Saving network.") ann.Save("robot_float.net") fmt.Println("Cleaning up.") train_data.Destroy() test_data.Destroy() ann.Destroy() }