1.建立識別座標系的感知機

         /**
	 * @author Ragty
	 * @param  建立識別座標系的感知機
	 * @serialData 2018.4.22
	 * @param inputNerouCount
	 * @param outputNeurophCount
	 */
	public void creatNetwork(int inputNerouCount, int outputNeurophCount){
		
		//定義感知機型別
		this.setNetworkType(NeuralNetworkType.PERCEPTRON);
		
		//建立輸入神經元,表示輸入的刺激
		NeuronProperties inputNeuronProperties = new NeuronProperties();
		inputNeuronProperties.setProperty("neuronType", InputNeuron.class);
		
		//輸入神經元構建的輸入層
		Layer inputLayer = LayerFactory.createLayer(inputNerouCount, inputNeuronProperties);
		this.addLayer(inputLayer);
		
		//設定傳遞函式為step函式(即為是大於0為1,小於等於1為0)
		NeuronProperties outputNeuronProperties = new NeuronProperties();
		outputNeuronProperties.setProperty("transferFunction",TransferFunctionType.STEP);
		
		//指定輸出層包含兩個神經元
		Layer outputLayer = LayerFactory.createLayer(outputNeurophCount, outputNeuronProperties);
		this.addLayer(outputLayer);
		
		//輸入輸出層全連線
		ConnectionFactory.fullConnect(inputLayer, outputLayer);
		NeuralNetworkFactory.setDefaultIO(this);
		
		//設定連線權重(直接關係到神經網路能否正常工作)分 別為[1 0] [0 1]
		//因為要區分四個象限對應為[1,1] [0,1] [0,0] [1,0] stpe函式中負數表示為0
		//根據公式的話,以第一象限為例,要求第一想想上邊得出的結果必須為1,下邊得出的結果也必須為1
		//據此可推斷出權重為 [1 0] [0 1]
		Neuron n = outputLayer.getNeuronAt(0);
		n.getInputConnections()[0].getWeight().setValue(1);   
		n.getInputConnections()[1].getWeight().setValue(0);
		
		n = outputLayer.getNeuronAt(1);
		n.getInputConnections()[0].getWeight().setValue(0);
		n.getInputConnections()[1].getWeight().setValue(1);
		
	}
2.輸入兩個值,判斷為第幾象限
          public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		String line = null;          
		double[] input = new double[2];
		//兩個輸入,兩個輸出的感知機
		feelPos perceptron = new feelPos(2, 2);

		try {
			while ((line = in.nextLine())!= null){
				String[] numbers = line.split("[\\s|,|;]");
				input[0] = Double.parseDouble(numbers[0]);
				input[1] = Double.parseDouble(numbers[1]);
				
				perceptron.setInput(input);
				perceptron.calculate();
				double[] networkOutput = perceptron.getOutput();
				System.out.println(Arrays.toString(input)+ "=" +posToString(networkOutput));
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		
	}
	
	//判斷為第幾象限
	public static String posToString(double[] networkOutput ){
		if((networkOutput[0]+networkOutput[1])==2){
			return "第一象限";
		}else if((networkOutput[0]+networkOutput[1])==0){
			return "第三象限";
		}else if((networkOutput[0]-networkOutput[1])==1){
			return "第四象限";
		}
		return "第二象限";
	}
3.識別結果