九、再看手写识别问题(内含代码详解及订正)

本文详细探讨了神经网络在手写数字识别中的应用,结合《神经网络与深度学习》和NTU林轩田老师的《Machine Learning》课程,介绍了权重初始化、交叉熵代价函数和L2规范化等改进方法。文中提供了代码实现,包括defaultweightinitializer和largeweightinitializer,以及用于监控网络性能的标志位和Network.SGD方法。此外,还讨论了使用JSON保存和加载网络模型以确保兼容性。
摘要由CSDN通过智能技术生成

本博客主要内容为图书《神经网络与深度学习》和National Taiwan University (NTU)林轩田老师的《Machine Learning》的学习笔记,因此在全文中对它们多次引用。初出茅庐,学艺不精,有不足之处还望大家不吝赐教。

  本节结合之前几节《改进神经网络的学习方法》系列中提到的方法进行实现。我们将写出一个新的程序,network2.py, 这是一个对第一章中开发的 network.py 的改进版本。获取完整的代码请点击这里,我们首先看看函数的初始化。

class Network(object):

    def __init__(self, sizes, cost=CrossEntropyCost):
        """The list ``sizes`` contains the number of neurons in the respective
        layers of the network.  For example, if the list was [2, 3, 1]
        then it would be a three-layer network, with the first layer
        containing 2 neurons, the second layer 3 neurons, and the
        third layer 1 neuron.  The biases and weights for the network
        are initialized randomly, using
        ``self.default_weight_initializer`` (see docstring for that
        method).

        """
        self.num_layers = len(sizes)
        self.sizes = sizes
        self.default_weight_initializer()
        self.cost=cost

  其中self.default_weight_initializer()是默认权重初始化函数,它采用的为在《八、改进神经网络的学习方法(4):权重初始化》所提到的方法,使用均值为0,方差为 1n

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值