Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

CNeuralNetwork: Make Your Neural Network Learn Faster

, 12 Aug 2009
An article on making neural network learn faster
Neural_Network_VS2008.zip
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
Gyeongsang National University, South Korea
Indonesia Indonesia
from Indonesia with love... Smile | :)

| Advertise | Privacy | Mobile
Web04 | 2.8.140905.1 | Last Updated 12 Aug 2009
Article Copyright 2009 by auralius manurung
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid