High-performance learning systems using low-precision nanoscale devices