Refactored DeepNeuralNetwork and BatchAllocator.