why can't my perceptron learn correctly?
hi, my perceptron seems not to be able of calculating the correct output if the output is bigger than the weights :(, here's my code...
Code:
#include <stdio.h>
#define LR 0.1
int wantedout;
int out;
int input1=0;
int input2=1;
long weight1=50;
long weight2=50;
int error;
educate_net()
{
out = ((input1*weight1) + (input2*weight2));
error = out - wantedout;
weight1 = weight1 - (error*LR);
weight2 = weight2 - (error*LR);
}
int main(){
printf("wanted output:");
while(1==1){
scanf("%d", &wantedout);
while(wantedout != out){
educate_net();
printf("%d\n", out);
}
}
return 0;
}
so, if the wantedout is bigger than the weight1 and weight 2...it just goes to infinite loop, do you know why and how can i fix it? please...