layer_activations.py 1.1 KB
Newer Older
D
dzhwinter 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
#  Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
14 15 16 17 18 19
'''
Test all activations.
'''

from paddle.trainer_config_helpers import *

Q
qijun 已提交
20
settings(learning_rate=1e-4, batch_size=1000)
21 22 23 24 25 26

din = data_layer(name='input', size=100)

acts = [
    TanhActivation, SigmoidActivation, SoftmaxActivation, IdentityActivation,
    LinearActivation, ExpActivation, ReluActivation, BReluActivation,
Q
qijun 已提交
27 28
    SoftReluActivation, STanhActivation, AbsActivation, SquareActivation
]
29

Q
qijun 已提交
30 31 32 33 34
outputs([
    fc_layer(
        input=din, size=100, act=act(), name="layer_%d" % i)
    for i, act in enumerate(acts)
])