2016-09-25 42 views
2

我有兩個巨大的numpy權重和偏差陣列的CNN。我可以爲每個圖層設置權重(使用set_weights),但我沒有看到爲每個圖層設置偏差的方法。我該怎麼做呢?在CNN設置偏差

回答

0

您可以使用layer.set_weights(weights)來完成此操作。從文檔:

weights: a list of Numpy arrays. The number 
     of arrays and their shape must match 
     number of the dimensions of the weights 
     of the layer (i.e. it should match the 
     output of `get_weights`). 

你不只是把權重過濾器在那裏,但對於每個參數的層。您必須輸入砝碼的順序取決於layer.weights。您可以查看代碼或通過做類似

print([p.name for p in layer.weights]) 
打印圖層權重的名稱