博客
关于我
Numpy编写BP传播过程全解
阅读量:185 次
发布时间:2019-02-28

本文共 1822 字,大约阅读时间需要 6 分钟。

BP???Numpy??????

??

BP??????????????????????????????????????????????????????????????????????????BP?????????????????????????

?????BP????????????????????????????????????PyTorch?TensorFlow??????????????????????????????????????????????????????????????Numpy????BP?????????????????

???????????Numpy???BP????????????????????????????????????????????

????

????4?????????????????784??????128????1??64????2??10??????????????784?128?128?64?64?10?10?1???????????????

?????

  • ????784????
  • ???1?128????
  • ???2?64????
  • ????10????

?????

  • W1?784?128?
  • W2?128?64?
  • W3?64?10?
  • W4?10?1?

???????Sigmoid???????????

Sigmoid(x) = 1/(1 + e^(-x))

Sigmoid'(x) = Sigmoid(x) * (1 - Sigmoid(x))

????

???????????

  • data ??????MNIST??????????mnist.pkl.gz
  • mnist_loader.py?????MNIST???
  • BP_Numpy.py?BP????????????
  • 1. ?????

    ??????????

    def initialize_weights(shape):    np.random.seed(42)    return np.random.randn(*shape)

    ??????????????????????????????????

    2. ????

    ?????????

    def forward_propagation(inputs, weights, biases):    activation = sigmoid(np.dot(inputs, weights) + biases)    return activation, weights, biases

    ????????????????????

    3. ????

    ?????????

    def backward_propagation(outputs, targets, weights, biases):    loss = np.mean(np.sum((outputs - targets) ** 2))    delta = (outputs - targets) * sigmoid_derivative(outputs - targets)    gradients = np.dot(weights.T, delta) + biases.T    return loss, gradients

    ????????????

    4. ????

    ?????????

    def update_parameters(weights, biases, gradients, learning_rate):    weights -= gradients[0] * learning_rate    biases -= gradients[1] * learning_rate    return weights, biases

    ??????????????

    ????

    ??????????????

    • ????0.1
    • epoch??1000
    • ?????10

    ???????????????????????????????????????

    ??

    ??????????????????BP???????????????????????????????????????????Numpy????????????????

    ????BP????????????????PaperWeekly??????????????????

    转载地址:http://teoj.baihongyu.com/

    你可能感兴趣的文章
    Netty源码—4.客户端接入流程一
    查看>>
    Netty源码—4.客户端接入流程二
    查看>>
    Netty源码—5.Pipeline和Handler一
    查看>>
    Netty源码—6.ByteBuf原理二
    查看>>
    Netty源码—7.ByteBuf原理三
    查看>>
    Netty源码—7.ByteBuf原理四
    查看>>
    Netty源码—8.编解码原理二
    查看>>
    Netty源码解读
    查看>>
    Netty的Socket编程详解-搭建服务端与客户端并进行数据传输
    查看>>
    Netty相关
    查看>>
    Network Dissection:Quantifying Interpretability of Deep Visual Representations(深层视觉表征的量化解释)
    查看>>
    Network Sniffer and Connection Analyzer
    查看>>
    NetworkX系列教程(11)-graph和其他数据格式转换
    查看>>
    Networkx读取军械调查-ITN综合传输网络?/读取GML文件
    查看>>
    Net与Flex入门
    查看>>
    net包之IPConn
    查看>>
    NFinal学习笔记 02—NFinalBuild
    查看>>
    NFS共享文件系统搭建
    查看>>
    nfs复习
    查看>>
    NFS网络文件系统
    查看>>