深度学习二:自己写java代码,识别手写数字

本文介绍了作者使用Java实现的全连接神经网络来识别手写数字的过程。通过加载MNIST数据集,构建四层神经网络并进行训练,最终达到约70%的识别准确率。此外,作者还分享了自己重构后的卷积神经网络CupCnn,该网络在MNIST数据集上的准确率提升到了99%。
摘要由CSDN通过智能技术生成

上一节我们自己写代码训练了只有一个神经元的反相器,它虽然只有一点点代码,但却让我们加深了梯度下降算法和反向传播算法的理解。只要勇敢的迈出这一步后,我们就可以勇敢的尝试它:深度学习中的hello wold–识别手写数字。

只有自己写过的代码,才能完全的理解它的用意,不管它多烂,多糟糕,它确是完全属于你的东西。在训练处反相器以后,我开始大胆的尝试自己写一个全连接的神经网络,来训练手写数字。这并不难,也不需要多少代码,我大概花了半天的时间就写完了所有的代码,你也不妨来试试…
你也可以到这里下载源码:
mnist-java
代码结构如下:
这里写图片描述

可以看到,我的思路是这样的:
神经网络(NerualNetwork)由层(Layer)构成,层(Layer)由神经元构成(Nerve)。这种思路非常直观,但它似乎并不是很好的设计,因为代码显得比较繁琐。希望你能设计出更好的结构,或许取消Nerve对象,所有逻辑都放在Layer中更好,这样会大量用到二维数组…

impo
Code provided by Ruslan Salakhutdinov and Geoff Hinton Permission is granted for anyone to copy, use, modify, or distribute this program and accompanying programs and documents for any purpose, provided this copyright notice is retained and prominently displayed, along with a note saying that the original programs are available from our web page. The programs and documents are distributed without any warranty, express or implied. As the programs were written for research purposes only, they have not been tested to the degree that would be advisable in any important application. All use of these programs is entirely at the user's own risk. How to make it work: 1. Create a separate directory and download all these files into the same directory 2. Download from http://yann.lecun.com/exdb/mnist the following 4 files: o train-images-idx3-ubyte.gz o train-labels-idx1-ubyte.gz o t10k-images-idx3-ubyte.gz o t10k-labels-idx1-ubyte.gz 3. Unzip these 4 files by executing: o gunzip train-images-idx3-ubyte.gz o gunzip train-labels-idx1-ubyte.gz o gunzip t10k-images-idx3-ubyte.gz o gunzip t10k-labels-idx1-ubyte.gz If unzipping with WinZip, make sure the file names have not been changed by Winzip. 4. Download Conjugate Gradient code minimize.m 5. Download Autoencoder_Code.tar which contains 13 files OR download each of the following 13 files separately for training an autoencoder and a classification model: o mnistdeepauto.m Main file for training deep autoencoder o mnistclassify.m Main file for training classification model o converter.m Converts raw MNIST digits into matlab format o rbm.m Training RBM with binary hidden and binary visible units o rbmhidlinear.m Training RBM with Gaussian hidden and binary visible units o backprop.m Backpropagation for fine-tuning an autoencoder o backpropclassify.m Backpropagation for classification using "encoder" network o CG_MNIST.m Conjugate Gradient optimization for fine-tuning an autoencoder o CG_CLASSIFY_INIT.m Co
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值