Keras的Layer其實就是一個Class, 要具有以下幾個方法:
(1) build(input_shape): 定義權重的地方, 如果不需要定義權重, 也要有self.built = True;
(2) call(x): 撰寫功能邏輯的地方, 實作Layer的功能邏輯;
(3) compute_output_shape(input_shape): 根據input_shape, 計算形狀變化的地方, 能夠讓Keras推斷輸出的Tensor的Shape.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/51647.html
標籤:其他
