File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 22from __future__ import division
33from __future__ import print_function
44
5+ from .. import config
56from ..backend import tf
67
78
89def linear (x ):
910 return x
1011
1112
13+ def layer_wise_locally_adaptive (activation , n = 1 ):
14+ """Layer-wise locally adaptive activation functions (L-LAAF).
15+ Jagtap et al., arXiv preprint arXiv:1909.12228, 2019.
16+
17+ Examples:
18+ To define a L-LAAF ReLU with the scaling factor ``n = 10``
19+ ```python
20+ n = 10
21+ activation = f"LAAF-{n} relu" # "LAAF-10 relu"
22+ ```
23+ """
24+ a = tf .Variable (1 / n , dtype = config .real (tf ))
25+ return lambda x : activation (n * a * x )
26+
27+
1228def get (identifier ):
1329 if identifier is None :
1430 return linear
1531 if isinstance (identifier , str ):
32+ if identifier .startswith ("LAAF" ):
33+ identifier = identifier .split ()
34+ n = float (identifier [0 ].split ("-" )[1 ])
35+ return layer_wise_locally_adaptive (get (identifier [1 ]), n = n )
1636 return {
1737 "elu" : tf .nn .elu ,
1838 "relu" : tf .nn .relu ,
You can’t perform that action at this time.
0 commit comments