这里的pipeline就是多了下载数据,解压数据,根据标签把数据分到不同目录的工作,其实也没什么新鲜的,贴代码
/** * This code example is featured in this youtube video * https://www.youtube.com/watch?v=ECA6y6ahH5E * ** This differs slightly from the Video Example, * The Video example had the data already downloaded * This example includes code that downloads the data * * * The Data Directory mnist_png will have two child directories training and testing//手写图片目录有两个目录,一个训练,一个测试 * The training and testing directories will have directories 0-9 with//这俩目录有0-9的28*28图片 * 28 * 28 PNG images of handwritten images * * * * The data is downloaded from * wget http://github.com/myleott/mnist_png/raw/master/mnist_png.tar.gz * followed by tar xzvf mnist_png.tar.gz * * * * This examples builds on the MnistImagePipelineExample * by adding a Neural Net */ public class MnistImagePipelineExampleAddNeuralNet { private static Logger log = LoggerFactory.getLogger(MnistImagePipelineExampleAddNeuralNet.class); /** Data URL for downloading */从哪下的数据 public static final String DATA_URL = "http://github.com/myleott/mnist_png/raw/master/mnist_png.tar.gz"; /** Location to save and extract the training/testing data *///数据位置 public static final String DATA_PATH = FilenameUtils.concat(System.getProperty("java.io.tmpdir"), "dl4j_Mnist/"); public static void main(String[] args) throws Exception { // image information // 28 * 28 grayscale // grayscale implies single channel int height = 28;//28*28的灰度图,1个过滤器,随机数生成器,128个图片为一批,10个类别,步数为1 int width = 28; int channels = 1; int rngseed = 123; Random randNumGen = new Random(rngseed); int batchSize = 128; int outputNum = 10; int numEpochs = 1; /* This class downloadData() downloads the data stores the data in java's tmpdir 15MB download compressed It will take 158MB of space when uncompressed The data can be downloaded manually here http://github.com/myleott/mnist_png/raw/master/mnist_png.tar.gz *///下面的方法下载数据到tmpdir目录,原始数据15MB解压后158MB,也可以手动下 downloadData();//调用