package ann;
import java.io.*;
import java.util.*;
public class App {
public static void main(String[] args) {
/*Perceptron aPerceptron=new Perceptron(2);
double[][] trainIn={{6,2},{7,1},{4,3},{3,4},{12.4,15},{4,8},{3,10},{10,3}};
int[] d={0,0,0,1,1,1,1,0};
aPerceptron.train(trainIn,d);
double[] in={4.5,5};
aPerceptron.setInput(in);
System.out.println(aPerceptron.getOutput());
*/
double[][] trainInput;
int[] expectation;
int inputCount=0,trainCount=0;
Perceptron aPerceptron;
Scanner scanner;
try {
scanner=
new Scanner(new BufferedReader(new FileReader(new File("train.txt"))));
inputCount=scanner.nextInt();
trainCount=scanner.nextInt();
trainInput=new double[trainCount][inputCount];
expectation=new int[trainCount];
for(int i=0;i
for(int j=0;j
trainInput[i][j]=scanner.nextDouble();
}
expectation[i]=scanner.nextInt();
}
aPerceptron=new Perceptron(inputCount);
aPerceptron.train(trainInput,expectation);
Scanner enter=new Scanner(System.in);
double[] test=new double[inputCount];
while (true) {
for (int i = 0; i < test.length; i++)
test[i] = enter.nextDouble();
aPerceptron.setInput(test);
System.out.println(aPerceptron.getOutput());
}
} catch (FileNotFoundException e) {
e.printStackTrace();
System.exit(0);
}
}
}
|