Skip to content

Commit 6e3376e

Browse files
authored
fix(US-BF-013): Extend ActivationFunctionFactory mappings (ReLU/Sigmoid/Tanh/Identity/LeakyReLU/ELU/SELU/Softplus/SoftSign/Swish/GELU) (#151)
1 parent 14eda96 commit 6e3376e

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/Factories/ActivationFunctionFactory.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ public static IActivationFunction<T> CreateActivationFunction(ActivationFunction
4848
{
4949
ActivationFunction.ReLU => new ReLUActivation<T>(),
5050
ActivationFunction.Softmax => throw new NotSupportedException("Softmax is not applicable to single values. Use CreateVectorActivationFunction for Softmax."),
51+
ActivationFunction.Sigmoid => new SigmoidActivation<T>(),
52+
ActivationFunction.Tanh => new TanhActivation<T>(),
53+
ActivationFunction.Identity => new IdentityActivation<T>(),
54+
ActivationFunction.LeakyReLU => new LeakyReLUActivation<T>(),
55+
ActivationFunction.ELU => new ELUActivation<T>(),
56+
ActivationFunction.SELU => new SELUActivation<T>(),
57+
ActivationFunction.Softplus => new SoftPlusActivation<T>(),
58+
ActivationFunction.SoftSign => new SoftSignActivation<T>(),
59+
ActivationFunction.Swish => new SwishActivation<T>(),
60+
ActivationFunction.GELU => new GELUActivation<T>(),
5161
_ => throw new NotImplementedException($"Activation function {activationFunction} not implemented.")
5262
};
5363
}
@@ -77,7 +87,17 @@ public static IVectorActivationFunction<T> CreateVectorActivationFunction(Activa
7787
return activationFunction switch
7888
{
7989
ActivationFunction.Softmax => new SoftmaxActivation<T>(),
90+
ActivationFunction.Sigmoid => new SigmoidActivation<T>(),
91+
ActivationFunction.Tanh => new TanhActivation<T>(),
92+
ActivationFunction.Identity => new IdentityActivation<T>(),
93+
ActivationFunction.LeakyReLU => new LeakyReLUActivation<T>(),
94+
ActivationFunction.ELU => new ELUActivation<T>(),
95+
ActivationFunction.SELU => new SELUActivation<T>(),
96+
ActivationFunction.Softplus => new SoftPlusActivation<T>(),
97+
ActivationFunction.SoftSign => new SoftSignActivation<T>(),
98+
ActivationFunction.Swish => new SwishActivation<T>(),
99+
ActivationFunction.GELU => new GELUActivation<T>(),
80100
_ => throw new NotImplementedException($"Vector activation function {activationFunction} not implemented.")
81101
};
82102
}
83-
}
103+
}

0 commit comments

Comments
 (0)