Activation.elu constructor

Activation.elu()

ELU (Exponential Linear Unit) activation function

elu(x) = x if x > 0 else a(e^x - 1)

Example:

final elu = Activation.elu();
final x = Matrix.row([-1, 1]);
final y = elu.function(x);
final y2 = elu.function(x, 0.3);
print(y); // output: matrix 1⨯2 [[-0.06321205588285576, 1.0]]
print(y2); // output: matrix 1⨯2 [[-0.1896361676485673, 1.0]]

Implementation

Activation.elu() {
  function = (Matrix m, [dynamic alpha = 0.1]) => m
      .apply((double x) => x > 0 ? x : (alpha as double) * (math.exp(x) - 1));
  dfunction = (Matrix m, [dynamic alpha = 0.1]) =>
      [m.apply((double x) => x > 0 ? 1 : (alpha as double) * math.exp(x))];
  name = 'elu';
}