Last active
March 29, 2022 00:59
-
-
Save SamJakob/4dcdc1a025e16d8562f29c7114f596de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tensorflow.keras import backend as K | |
@tensorflow.function | |
def angeleaky_elu(x, alpha=1.0): | |
""" | |
Custom activation function that introduces a bias between 0 < x < 0.5 to | |
'throttle' the positive values that the network is not confident in. | |
""" | |
return K.switch( | |
x <= 0, K.elu(x, alpha), | |
K.switch( | |
x >= 0.5, K.elu(x, alpha), | |
K.elu(x, alpha) / 3 | |
) | |
) | |
@tensorflow.function | |
def angeleaky_relu(x, alpha=1.0): | |
""" | |
Custom activation function that introduces a bias between 0 < x < 0.5 to | |
'throttle' the positive values that the network is not confident in. | |
""" | |
return K.switch( | |
x <= 0, K.relu(x, alpha), | |
K.switch( | |
x >= 0.5, K.relu(x, alpha), | |
K.relu(x, alpha) / 3 | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment