https://www.pythonmorsels.com/p/22cjj/
各位好, 想问上面line 345 vs line 346 一个true 一个False
都使用forward但是output不同....
贴上来如下
den = Dense(784, 150)
den.weight = model.layers[0].params[0]
den.bias = model.layers[0].params[1]
-> oout1_0 = den.forward(out1[0])
denn = NN()
denn.add_layer(Dense(784, 150))
denn.params.append(model.layers[0].params)
-> oout1, _ = denn.forward(out1[0])
oout3 = np.dot(out1[0], model.layers[0].params[0]) +
model.layers[0].params[1]
print((oout1 == oout1_0).all()) # False
print((oout3 == oout1_0).all()) # True
而
class Dense():
def __init__(self, input_node, output_node):
......
......
def forward(self, x):
self.x = x # self.x is the input
self.output = np.dot(x, self.weight) + self.bias # generate output
from self.x
return self.output
另外想问 save_parameter跟load parameter有没有写错呢orz