Accelerator for neural networks