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

    你可能感兴趣的文章
    Vue.js 学习总结(12)—— 微前端实践思考与总结
    查看>>
    oldboy.16课
    查看>>
    OLEDB IMEX行数限制的问题
    查看>>
    ollama 如何删除本地模型文件?
    查看>>
    ollama-python-Python快速部署Llama 3等大型语言模型最简单方法
    查看>>
    Ollama怎么启动.gguf 大模型
    查看>>
    ollama本地部署DeepSeek(Window图文说明)
    查看>>
    ollama运行多模态模型如何进行api测试?
    查看>>
    OMG,此神器可一次定一周的外卖
    查看>>
    Omi 多端开发之 - omip 适配 h5 原理揭秘
    查看>>
    On Error GOTO的好处
    查看>>
    onclick事件的基本操作
    查看>>
    oncopy和onpaste
    查看>>
    onCreate中的savedInstanceState作用
    查看>>
    onCreate()方法中的参数Bundle savedInstanceState 的意义用法
    查看>>
    One good websit for c#
    查看>>
    One-Shot学习/一次学习(One-shot learning)
    查看>>
    OneASP 安全公开课,深圳站, Come Here, Feel Safe!
    查看>>
    OneBlog Shiro 反序列化漏洞复现
    查看>>
    oneM2M
    查看>>