我想建立一个代码,可以计算矩阵乘法在神经网络没有张量流或美国运输部或者np.材料. 在
以下是我感兴趣的代码片段:
class Affine:
def __init__(self, W, b):
self.W = W
self.b = b
self.x = None
self.original_x_shape = None
self.dW = None
self.db = None
def forward(self, x):
self.original_x_shape = x.shape
x = x.reshape(x.shape[0], -1)
self.x = x
out = np.dot(self.x, self.W) + self.b
return out
该代码是神经网络(X*W+b)正向计算的一部分。而且效果很好。在
我想修改out = np.dot(self.x, self.W) + self.b
行。它应该以同样的方式工作美国运输部或者np.材料. 在
以下是我的代码:
^{pr2}$修改部分只是并行矩阵乘法。但是,发生了以下错误:AttributeError: Can't pickle local object 'Affine2.forward.<locals>.matmult'
我怎么解决这个问题?在
目前没有回答
相关问题 更多 >
编程相关推荐