Activations
Keras to DL4J activation function mapping for model import
Last updated
Was this helpful?
Was this helpful?
softmax(x)_i = exp(x_i) / sum(exp(x_j))elu(x) = x if x >= 0
alpha * (exp(x) - 1) if x < 0selu(x) = lambda * x if x > 0
lambda * alpha * (exp(x) - 1) if x <= 0softplus(x) = log(1 + exp(x))softsign(x) = x / (1 + |x|)relu(x) = max(0, x)tanh(x) = (exp(x) - exp(-x)) / (exp(x) + exp(-x))sigmoid(x) = 1 / (1 + exp(-x))hard_sigmoid(x) = 0 if x < -2.5
1 if x > 2.5
0.2*x + 0.5 otherwiselinear(x) = xfrom keras.layers import Dense
# Activation as a string parameter
model.add(Dense(64, activation='relu'))
model.add(Dense(10, activation='softmax'))from keras.layers import Dense, Activation
model.add(Dense(64))
model.add(Activation('relu'))