O'Reilly logo

Java Deep Learning Projects by Md. Rezaul Karim

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Flattening input for the input layer

Then we need to convert the output of the network into a 1D-feature vector, to be used by the DQN. This flattening gets the output of the network; it flattens all its structure to create a single long-feature vector to be used by the dense layer. Take a look at this code:

INDArray flattenInput(int TimeStep) {        float flattenedInput[] = new float[size * size * 2 + 1];        for(int a = 0; a < size; a++) {            for(int b = 0; b < size; b++) {                if(FrameBuffer[a][b] == -1)                    flattenedInput[a * size + b] = 1;                else                    flattenedInput[a * size + b] = 0;                if(FrameBuffer[a][b] == 1)                    flattenedInput[size * size + a * size + b] = 1;                else                    flattenedInput[size * size + a * size + b] = 0;            }        }        flattenedInput[size * size * 2] = TimeStep;        

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required