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

    你可能感兴趣的文章
    nsis 安装脚本示例(转)
    查看>>
    NSJSON的用法(oc系统自带的解析方法)
    查看>>
    nslookup 的基本知识与命令详解
    查看>>
    NSOperation基本操作
    查看>>
    NSRange 范围
    查看>>
    NSSet集合 无序的 不能重复的
    查看>>
    NSURLSession下载和断点续传
    查看>>
    NSUserdefault读书笔记
    查看>>
    NS图绘制工具推荐
    查看>>
    NT AUTHORITY\NETWORK SERVICE 权限问题
    查看>>
    NT symbols are incorrect, please fix symbols
    查看>>
    ntelliJ IDEA 报错:找不到包或者找不到符号
    查看>>
    NTFS文件权限管理实战
    查看>>
    ntko web firefox跨浏览器插件_深度比较:2019年6个最好的跨浏览器测试工具
    查看>>
    ntko文件存取错误_苹果推送 macOS 10.15.4:iCloud 云盘文件夹共享终于来了
    查看>>
    ntp server 用法小结
    查看>>
    ntpdate 通过外网同步时间
    查看>>
    NTPD使用/etc/ntp.conf配置时钟同步详解
    查看>>
    NTP及Chrony时间同步服务设置
    查看>>
    NTP配置
    查看>>