上一节我们自己写代码训练了只有一个神经元的反相器,它虽然只有一点点代码,但却让我们加深了梯度下降算法和反向传播算法的理解。只要勇敢的迈出这一步后,我们就可以勇敢的尝试它:深度学习中的hello wold–识别手写数字。
只有自己写过的代码,才能完全的理解它的用意,不管它多烂,多糟糕,它确是完全属于你的东西。在训练处反相器以后,我开始大胆的尝试自己写一个全连接的神经网络,来训练手写数字。这并不难,也不需要多少代码,我大概花了半天的时间就写完了所有的代码,你也不妨来试试…
你也可以到这里下载源码:
mnist-java
代码结构如下:
可以看到,我的思路是这样的:
神经网络(NerualNetwork)由层(Layer)构成,层(Layer)由神经元构成(Nerve)。这种思路非常直观,但它似乎并不是很好的设计,因为代码显得比较繁琐。希望你能设计出更好的结构,或许取消Nerve对象,所有逻辑都放在Layer中更好,这样会大量用到二维数组…
impo