Skip to content

Commit b4ea1a3

Browse files
committed
feat(layer): add ActivationFunction init as string in Activation
1 parent 4280565 commit b4ea1a3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

neuralnetlib/layers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,10 @@ def from_config(config: dict):
213213

214214

215215
class Activation(Layer):
216-
def __init__(self, activation_function: ActivationFunction):
216+
def __init__(self, activation_function: ActivationFunction | str):
217217
super().__init__()
218-
self.activation_function = activation_function
218+
self.activation_function = activation_function if isinstance(
219+
activation_function, ActivationFunction) else ActivationFunction.from_name(activation_function)
219220

220221
def __str__(self) -> str:
221222
name = type(self.activation_function).__name__

0 commit comments

Comments
 (0)