June 2018
Intermediate to advanced
436 pages
10h 33m
English
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; Read now
Unlock full access