Click here to Skip to main content
13,041,923 members (61,531 online)
Click here to Skip to main content

Stats

32.8K views
1.2K downloads
65 bookmarked
Posted 12 Aug 2009

CNeuralNetwork: Make Your Neural Network Learn Faster

, 12 Aug 2009
An article on making neural network learn faster
Neural Network_VS
Neural Network
Neural Network-Demo.exe
Neural Network.vcproj.RIS-808E3E7FF65.exeskeleton.user
SPECT.train
// Neural Network.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "Neural Network.h"


int main()
{
	CNeuralNetwork nn;
	nn.ann_set_learning_rate(0.5);
	nn.ann_set_momentum(0);
	nn.ann_set_lr_changing_factor(0);
	nn.ann_set_slope_value(1);
	nn.ann_set_weight_init_method(nn.RANDOM);
	nn.ann_create_network(2,1,1,3);
	//nn.ann_create_network(22,1,4,30,30,30,30);
	//nn.ann_train_network_from_file("SPECT.train", 500, 0.001, 1);
	nn.ann_train_network_from_file("input.txt", 500, 0.01,nn.OUTPUT_FIRST);
	printf("number of epoch: %i with final error: %f\n", nn.ann_get_epoch_num(), nn.ann_get_average_error());

	nn.ann_set_input_per_channel(0, 1.0F);
	nn.ann_set_input_per_channel(1, 1.0F);
	nn.ann_simulate();
	printf("1 XOR 1 is %f\n", nn.ann_get_output(0));

	nn.ann_set_input_per_channel(0, 0.0F);
	nn.ann_set_input_per_channel(1, 0.0F);
	nn.ann_simulate();
	printf("0 XOR 0 is %f\n", nn.ann_get_output(0));

	nn.ann_set_input_per_channel(0, 1.0F);
	nn.ann_set_input_per_channel(1, 0.0F);
	nn.ann_simulate();
	printf("1 XOR 0 is %f\n", nn.ann_get_output(0));

	nn.ann_set_input_per_channel(0, 0.0F);
	nn.ann_set_input_per_channel(1, 1.0F);
	nn.ann_simulate();
	printf("0 XOR 1 is %f\n", nn.ann_get_output(0));

	nn.ann_test_network_from_file("input.txt", "log.txt", nn.OUTPUT_FIRST);

	nn.ann_clear();
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

auralius manurung
Student
Indonesia Indonesia
http://kataauralius.com/

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 12 Aug 2009
Article Copyright 2009 by auralius manurung
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid