Open Marfein opened 1 year ago
public static void main(String[] args) { double[][] andInputs = {{0, 0}, {0, 1}, {1, 0}, {1, 1}}; int[] andOutputs = {0, 0, 0, 1}; Perceptron andPerceptron = new Perceptron(2); andPerceptron.train(andInputs, andOutputs, 0.1, 100); System.out.println("AND gate:"); System.out.println("0 AND 0 = " + andPerceptron.classify(new double[]{0, 0})); System.out.println("0 AND 1 = " + andPerceptron.classify(new double[]{0, 1})); System.out.println("1 AND 0 = " + andPerceptron.classify(new double[]{1, 0})); System.out.println("1 AND 1 = " + andPerceptron.class
import java.util.Arrays;
public class Perceptron { private double[] weights; private double threshold;
}