博客
关于我
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/

    你可能感兴趣的文章
    Oracle SOA Suit Adapter
    查看>>
    Oracle Spatial GeoRaster 金字塔栅格存储
    查看>>
    Oracle Spatial空间数据库建立
    查看>>
    UML— 活动图
    查看>>
    oracle sqlplus已停止工作,安装完成客户端后sqlplus报“段错误”
    查看>>
    Oracle Statspack分析报告详解(一)
    查看>>
    oracle tirger_在Oracle中,临时表和全局临时表有什么区别?
    查看>>
    oracle where 条件的执行顺序分析1
    查看>>
    Oracle 中的 decode
    查看>>
    oracle 使用leading, use_nl, rownum调优
    查看>>
    oracle 修改字段类型方法
    查看>>
    oracle 内存参数示意图
    查看>>
    Oracle 写存储过程的一个模板还有一些基本的知识点
    查看>>
    UML- 配置图(部署图)
    查看>>
    Oracle 创建 DBLink 的方法
    查看>>
    oracle 创建job
    查看>>
    oracle 创建双向备份,Materialized View 物化视图实现 Oracle 表双向同步
    查看>>
    oracle 创建字段自增长——两种实现方式汇总
    查看>>
    Oracle 升级10.2.0.5.4 OPatch 报错Patch 12419392 Optional component(s) missing 解决方法
    查看>>
    oracle 可传输的表空间:rman
    查看>>