A Scalable Near-Memory Architecture for Training Deep Neural Networks on Large In-Memory Datasets