Deeplearning4j

So, now that we've covered ND4J, we want to actually create our neural network. So let's start with the famous XOR example, which actually trains a neural network for learning XOR.

Let's first generate some training data inline:

/*      * list off input values, 4 training samples with data for 2 input-neurons each      */     var input: INDArray = Nd4j.zeros(4, 2)      /*      *  correspondending list with expected output values, 4 training samples with      *  data for 2 output-neurons each      */     var labels: INDArray = Nd4j.zeros(4, 2);      /*      *  create first dataset when first input=0 and second input=0      */     input.putScalar(Array(0, 0), 0);     input.putScalar(Array(0, 1), 0);      /*      *  then the first output fires for false, and the second is 0 (see class comment) */ ...

Get Mastering Apache Spark 2.x - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.