深度学习:多层感知机MLP数字识别的代码实现

深度学习我看的是neural network and deep learning 这本书,这本书写的真的非常好,是我的导师推荐的。这篇博客里的代码也是来自于这,我最近是在学习Pytorch,学习的过程我觉得还是有必要把代码自己敲一敲,就像当初学习机器学习一样。也是希望通过这个代码能够加深对反向传播原路的认识。

在下面的代码中,比较复杂的部分就是mini_batch部分了,我们一定要有清晰的认识,我们在上一篇博客中给出了反向传播方法四公式,而且在文章的末尾又给出了使用这四个公式的方法。

这里写图片描述

所以牢牢记住这个个流程,一共分为:
1.输入训练集
2.前向传播
3.计算输出层产生的错误
4.反向传播的错误
5.使用梯度下降,训练参数

我们将在下面的代码中用以上的几个数字(1到5)来表示当前代码是哪个过程

import random
import mnist_loader

import numpy as np

class Network(object):

def __init__(self, sizes):
    """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 a Gaussian
    distribution with mean 0, and variance 1.  Note that the first
    layer is assumed to be an input layer, and by convention we
    won't set any biases
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值