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