最后我们再写3篇基于spark的深度学习,这篇是手写识别的,用的是spark的local模式,如果想用集群模式在submit的时候设置-useSparkLocal false,或者在程序中设置useSparkLocal=false,代码如下
public class MnistMLPExample { private static final Logger log = LoggerFactory.getLogger(MnistMLPExample.class); @Parameter(names = "-useSparkLocal", description = "Use spark local (helper for testing/running without spark submit)", arity = 1)//@Parameter这个是参数的意思,参数名是sparklocal,下面的true代表使用local模式,arity=1代表这个参数消费一个参数值 private boolean useSparkLocal = true; @Parameter(names = "-batchSizePerWorker", description = "Number of examples to fit each worker with")//每个worker训练多少个例子,下面指定了16 private int batchSizePerWorker = 16; @Parameter(names = "-numEpochs", description = "Number of epochs for training")//训练的步数,下面指定了15 private int numEpochs = 15; public static void main(String[] args) throws Exception {