看板 Python 關於我們 聯絡資訊
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 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.140.90.201 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1667400516.A.C0B.html
lycantrope: 因為denn.append_layer的Dense,沒有給一樣的weight 11/03 09:43