@@ -0,0 +1,3066 @@
+package common;%0A%0Aimport org.deeplearning4j.nn.api.OptimizationAlgorithm;%0Aimport org.deeplearning4j.nn.conf.MultiLayerConfiguration;%0Aimport org.deeplearning4j.nn.conf.NeuralNetConfiguration;%0Aimport org.deeplearning4j.nn.conf.layers.DenseLayer;%0Aimport org.deeplearning4j.nn.conf.layers.OutputLayer;%0Aimport org.deeplearning4j.nn.multilayer.MultiLayerNetwork;%0Aimport org.nd4j.linalg.activations.Activation;%0Aimport org.nd4j.linalg.api.ndarray.INDArray;%0Aimport org.nd4j.linalg.dataset.DataSet;%0Aimport org.nd4j.linalg.factory.Nd4j;%0Aimport org.nd4j.linalg.lossfunctions.LossFunctions;%0A%0A/***%0A * XOR Problem based on FNN and treat it as a regression problem rather than classification%0A */%0Apublic class XOR %7B%0A    public static void main(String%5B%5D args)%7B%0A        int seed = 1234567;%0A        int iterations = 1;%0A        MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()%0A                                .seed(seed)%0A                                .iterations(iterations)%0A                                .learningRate(0.01)%0A                                .miniBatch(false)%0A                                .useDropConnect(false)%0A                                .optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)%0A                                .list()%0A                                .layer(0, new DenseLayer.Builder()%0A                                                        .nIn(2)%0A                                                        .nOut(2).activation(Activation.RELU)//Activation.RELU will not work%0A                                                                                            //since non-linear transformation%0A                                                                                            //is needed here%0A                                                        .build())%0A                                .layer(1, new OutputLayer.Builder(LossFunctions.LossFunction.MSE)%0A                                                         .activation(Activation.IDENTITY)%0A                                                         .nIn(2).nOut(1).build())%0A                                .backprop(true).pretrain(false)%0A                                .build();%0A        MultiLayerNetwork model = new MultiLayerNetwork(conf);%0A        model.init();        %0A        //%0A        double%5B%5D%5B%5D feature = %7B%7B0.0,0.0%7D,%7B0.0,1.0%7D,%7B1.0,0.0%7D,%7B1.0,1.0%7D%7D;%0A        double%5B%5D%5B%5D label = %7B%7B0.0%7D,%7B1.0%7D,%7B1.0%7D,%7B0.0%7D%7D;%0A        //%0A        INDArray ndFeature = Nd4j.create(feature);%0A        INDArray ndLabel = Nd4j.create(label);%0A        //%0A        DataSet ds = new DataSet(ndFeature, ndLabel);%0A        System.out.println(model.summary());%0A//        UIServer uiServer = UIServer.getInstance();%0A//        StatsStorage statsStorage = new InMemoryStatsStorage(); %0A//        model.setListeners(new StatsListener(statsStorage, 1));%0A//        uiServer.attach(statsStorage);%0A        for(int i = 1; i %3C= 500; ++i)model.fit(ds);%0A        INDArray output = model.output(ndFeature);%0A        System.out.println(output);%0A//        uiServer.stop();%0A        //%0A    %7D%0A%7D%0A

Create New Package And XOR Example