codebytes: Perceptron Learning Algorithm : Java Implementation
Tutorials: Do the following until stopping condition is satisfied: For each training instance (example) Calculate localError = true (known) output - given output adjust weights[] = weights[] + LEARNING_RATE*localError*x[i]; adjust weights[] = weights[] + LEARNING_RATE*localError*y[i]; update bias (weight[2] = weight[2] + LEARNING_RATE*localError;) update globalError = globalError + localError*localError; (squared error). The decision boundary equation is given by weights[0]*x + weights[1]*y + weights[2] = 0; Test the adjusted variables on randomly generated inputs. Java Implementation (Credits : Dr. Noureddin Sadawi) : public class CaltechEx1 { static int MAX_ITER = 100; static double LEARNING_RATE = 0.001; static int NUM_INSTANCES = 100; static int theta = 0; public static void main(String[] args){ //three variables (features) double[] x = new double[NUM_INSTANCES]; double[] y = new double[NUM_INSTANCES]; int[] outputs = new int[NUM_INSTANCES];Read full article from codebytes: Perceptron Learning Algorithm : Java Implementation
No comments:
Post a Comment