1 Star 0 Fork 0

tutoupfx / deep-learning

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
layer.py 596 Bytes
一键复制 编辑 原始数据 按行查看 历史
tutoupfx 提交于 2022-10-07 12:05 . feat:day1007
class MulLayer:
"""
乘法层
"""
def __init__(self):
self.x = None
self.y = None
def forward(self, x, y):
self.x = x
self.y = y
out = x * y
return out
def backward(self, dout):
dx = dout * self.y # 翻转x和y
dy = dout * self.x
return dx, dy
class AddLayer:
"""
加法层
"""
def __init__(self):
pass
def forward(self, x, y):
out = x + y
return out
def backward(self, dout):
dx = dout * 1
dy = dout * 1
return dx, dy
1
https://gitee.com/da9527/deep-learning.git
git@gitee.com:da9527/deep-learning.git
da9527
deep-learning
deep-learning
master

搜索帮助