keras 的 example 文件 antirectifier.py 解析
本站寻求有缘人接手,详细了解请联系站长QQ1493399855
该代码的功能是进行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,所以没有参数需要训练
——————————————————————
总目录