Derivative Rules
\[\begin{aligned}
&\frac{\delta E}{\delta w^1_{jk}}=\frac{\delta E}{\delta O_k^1}\frac{\delta O_k^1}{\delta w^1_{jk}}=\frac{\delta E}{\delta O_k^2}\frac{\delta O_k^2}{\delta O_k^1}\frac{\delta O_k^1}{\delta w^1_{jk}}\\
\end{aligned}
\]
import torch, torch.nn.functional as F
x = torch.tensor(1.)
w1, w2 = torch.tensor(2., requires_grad=True), torch.tensor(2., requires_grad=True)
b1, b2 = torch.tensor(1.), torch.tensor(1.)
y1 = x * w1 + b1
y2 = y1 * w2 +b2
dy2_dy1 = torch.autograd.grad(y2, [y1], retain_graph=True)[0]
dy1_dw1 = torch.autograd.grad(y1, [w1], retain_graph=True)[0]
dy2_dw1 = torch.autograd.grad(y2, [w1], retain_graph=True)[0]
dy2_dy1 * dy1_dw1
tensor(2.)
dy2_dw1
tensor(2.)

Pytorch Chain-Rules的更多相关文章

  1. 机器学习、NLP、Python和Math最好的150余个教程(建议收藏)

    编辑 | MingMing 尽管机器学习的历史可以追溯到1959年,但目前,这个领域正以前所未有的速度发展.最近,我一直在网上寻找关于机器学习和NLP各方面的好资源,为了帮助到和我有相同需求的人,我整 ...

  2. 超过 150 个最佳机器学习,NLP 和 Python教程

    超过 150 个最佳机器学习,NLP 和 Python教程 微信号 & QQ:862251340微信公众号:coderpai简书地址:http://www.jianshu.com/p/2be3 ...

  3. iptables Data filtering详解

    内容简介防火墙的概述iptables简介iptables基础iptables语法iptables实例案例详解(一)防火墙的简介防火墙是指设置在不同网络或网络安全域之间的一系列部件的组合,它能增强机构内 ...

  4. iptables 工具

    iptables 工具 参考文档: https://www.frozentux.net/iptables-tutorial/cn/iptables-tutorial-cn-1.1.19.html   ...

  5. Linux: 20 Iptables Examples For New SysAdmins

    Linux comes with a host based firewall called Netfilter. According to the official project site: net ...

  6. The Beginner’s Guide to iptables, the Linux Firewall

    Iptables is an extremely flexible firewall utility built for Linux operating systems. Whether you’re ...

  7. Linux 学习之防火墙配置

    1.安装iptables防火墙 yum install iptables  2. 清除已有的iptables规则  iptables -F  iptables -X  iptables -Z  3.显 ...

  8. Linux 命令行

    Linux 命令笔记 一.目录/文件 1.1 目录文件日常操作 . -> 当前目录 .. -> 上一级目录 .file/.dir -> 隐藏文件/文件夹 [ls] 查看指定目录文件 ...

  9. [转] XEN, KVM, Libvirt and IPTables

    http://cooker.techsnail.com/index.php/XEN,_KVM,_Libvirt_and_IPTables XEN, KVM, Libvirt and IPTables ...

  10. ubuntu 中DNAT SNAT配置实验.

    1.      目的 图1 如图1所示,有A,B两台计算机,其中A配置成普通PC,B是网关.实现由A向一个不存在的IP 发起tcp连接,并能向这个不存在的ip发送数据. 同时响应这个tcp连接的是B中 ...

随机推荐

  1. 家里静态Ip设置

    分配的网段是10.10.1.*

  2. HDLbits——Shift18

    // Build a 64-bit arithmetic shift register, // with synchronous load. The shifter can shift both le ...

  3. SAP 内外交货单过账

    * 交货单过账  DATA:  LS_HEADER_DATA           TYPE BAPIIBDLVHDRCON,              LS_HEADER_CONTROL   TYPE ...

  4. 整合mybatis-示例

    引入依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.o ...

  5. [jQuery]z-index属性大于0的元素使用fadeIn无法正常过渡的问题

    rt 问题记录. 尝试使用$('    ').animate({ opacity: 1 }) 会出现相同的问题. 可能是opacity动画与z-index无法兼容(?) 最后的处理方式是改变元素渲染顺 ...

  6. PIL画图只有黑白色

    背景 项目上需要对人工标注的图片上的框进行校对,验证有无漏框.错框等问题.尝试使用opencv把框信息画出来,但是中文无法写到图片上,么得办法,只能转战PIL.但是用PIL之后出现部分图画出来的框写出 ...

  7. 服务器部署 halo博客项目

    2020-8-9 13:45:14 有个进阶方法!  如果静态资源加载缓慢如图片,头像  则用CDN加速  (确实很秀!) https://cdn.jsdelivr.net/gh/你的用户名/你的仓库 ...

  8. 将字符串数组String[]转换成List的三种方法

    通过 Arrays.asList(strArray) 方式,将数组转换List后,不能对List增删,只能查改,否则抛异常. String[] strArray = new String[2]; Li ...

  9. Ubuntu 20.04 部署Prmoetheus+grafana+mysql+mysqld_exporter+node_exporter

    Prometheus简介 Prometheus是一个功能强大的开源监控系统,可从您的服务中收集指标并将其存储在时间序列数据库中.它通过Grafana等工具提供多维数据模型,灵活的查询语言和多样化的可视 ...

  10. 【2020NOI.AC省选模拟#6】A. zyb的监控计划

    题目链接 原题解: 考虑我们需要的信息:子树里最浅的一个能向上的点是谁?子树里最深的一个没被覆盖的深度是多少? 我们记录一下$f_{i,a,b}$表示上面两个信息为$a$和$b$的时候,最少要花费的代 ...