School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
Welcome to Dream.In.Code
Become an Expert!

Join 340,116 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 4,301 people online right now. Registration is fast and FREE... Join Now!



Can somebody please explain Back Propagation

Can somebody please explain Back Propagation Rate Topic: -----

#1 enigma-paradox  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: Members
  • Posts: 19
  • Joined: 16-June 08


Dream Kudos: 0

Posted 18 March 2009 - 07:35 AM

I don't understand back propagation, I just started trying to teach my self about neural netwoks. I believe I unserstand the concept of what a neuron is and how they work. The problem is that with out a way to train the network, the following code that I've written doesn't do much good. I also looked through the tutorials section, but all of the tutorials seem like they are geared towards learning a language(python, java, ruby,etc.) as opposed to learning a topic(cryptology, AI, data compression, etc.) If anybody could give me a thorough explanation of back propagation or any other way to train an ANN I would really appreciate it.

#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int get_input(void);
double sigmoid(double x);


int main()
{
	int nodes_in_input = 0;//This declares the number of nodes in the input layer
	int nodes_in_hidden = 0;//This declares the number of nodes in the hidden layer
	int nodes_in_output = 0;//This declares the number of nodes in the output layer
	int number_of_inputs = 0;//This is equal to the number of data points in the input data file
	int i = 0;
	int j = 0;
	int k = 0;
	double activation = 0;
	
	
	
	printf("How many nodes in the input layer:\n");
	nodes_in_input = get_input();
	printf("How many nodes in the hidden layer:\n");
	nodes_in_hidden = get_input();
	printf("How many nodes in the output layer:\n");
	nodes_in_output = get_input();
	
	double input_layer[nodes_in_input];
	double hidden_layer[nodes_in_hidden];
	double output_layer[nodes_in_output];
	double input_data[];
	double weights[nodes_in_input];
	
	for(i = 0; i<nodes_in_input; i++)
	{
		weights[i] = rand()/(RAND_MAX + 1.0);
	}
	
	for(k=0; k<nodes_in_input; k++)
	{
		double output = 0.0;
		double activation = 0.0;
		
		
		for(j=0; j<number_of_inputs; j++)
		{
			activation = activation + weights[j]*input_data[j];
			output = sigmoid(activation);
		}
		input_layer[i] = output;
	}
	
	for(i=0; i<nodes_in_hidden; i++)
	{
		double output = 0.0;
		double activation = 0.0;
		
		
		for(j=0; j<nodes_in_input; j++)
		{
			activation = activation + weights[j]*input_layer[j];
			sigmoid(activation);
			output = sigmoid(activation);
		}
		hidden_layer[i] = output;
	}
	
	for(i=0; i<nodes_in_output; i++)
	{
		double output = 0.0;
		double activation = 0.0;
		
		
		for(j=0; j<nodes_in_input; j++)
		{
			activation = activation + weights[j]*hidden_layer[j];
			sigmoid(activation);
			output = sigmoid(activation);
		}
		output_layer[i] = output;
	}
	return 0;
}

int get_input(void)
{
	while(1)
	{
		int number = 0;		
		if ( scanf("%d", &number) == 1 && number > 0)
		{
			return  number;		  
		}			  
			printf("Invalid input!\n");
			printf("Please try again\n");
			while (getchar() != '\n'); //Clears the input buffer
			  
	}
}

double sigmoid(double x)
{
	double p = 1.0;
	double output = 0.0;
	output = 1/(1+ exp(-x/p));
	return output;
}

Was This Post Helpful? 0
  • +
  • -


#2 enigma-paradox  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: Members
  • Posts: 19
  • Joined: 16-June 08


Dream Kudos: 0

Posted 18 March 2009 - 09:13 PM

Does nobody understand how back propagation works?!?
Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month