直接用一组实例,给大家展示演示要如何使用这个算法吧~
在BP算法中最常见的就是结合layer各种模块化结合使用,所以以下内容会包含这些。
示图:

结合使用BP算法以及layer模块代码演示:
class LinearLayer: def __init__(self, input_D, output_D): self._W = np.random.normal(0, 0.1, (input_D, output_D)) self._b = np.random.normal(0, 0.1, (1, output_D)) self._grad_W = np.zeros((input_D, output_D)) self._grad_b = np.zeros((1, output_D)) def forward(self, X): return np.matmul(X, self._W) + self._b
下一篇:如何学习python数据挖掘