keras 的 example 文件 antirectifier.py 解析
生活随笔
收集整理的這篇文章主要介紹了
keras 的 example 文件 antirectifier.py 解析
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
該代碼的功能是進行mnist的數字識別,主要是用于指導大家如何自己封裝一個層,也就是自定義層
這里的Antirectifier就是自定義的一個層,代碼是進行一個正則化,然后正向結果進行一個relu激活函數,和取反(負數)結果進行一個relu,之后再進行一個concatenate
輸入shape和輸出shape分別為:
(60000, 784)
(60000, 10)
神經網絡結構為:
________________________________________________________________________________
Layer (type) Output Shape Param #
================================================================================
dense_1 (Dense) (None, 256) 200960
________________________________________________________________________________
antirectifier_1 (Antirectifier) (None, 512) 0
________________________________________________________________________________
dropout_1 (Dropout) (None, 512) 0
________________________________________________________________________________
dense_2 (Dense) (None, 256) 131328
________________________________________________________________________________
antirectifier_2 (Antirectifier) (None, 512) 0
________________________________________________________________________________
dropout_2 (Dropout) (None, 512) 0
________________________________________________________________________________
dense_3 (Dense) (None, 10) 5130
________________________________________________________________________________
activation_1 (Activation) (None, 10) 0
================================================================================
Total params: 337,418
Trainable params: 337,418
Non-trainable params: 0
________________________________________________________________________________
不過可以看到,這里的Antirectifier層,參數個數為0,所以沒有參數需要訓練
?
——————————————————————
總目錄
keras的example文件解析
總結
以上是生活随笔為你收集整理的keras 的 example 文件 antirectifier.py 解析的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: keras 的 example 文件 a
- 下一篇: keras 的 example 文件 b