Skip to content
9 changes: 7 additions & 2 deletions ppsci/arch/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def init_for_hidden_layer(layer: nn.Linear, w0: float = 30):
"silu": Silu(),
"sin": Sin(),
"cos": Cos(),
"swish": Swish(),
"swish": Swish,
"tanh": nn.Tanh(),
"identity": nn.Identity(),
"siren": Siren(),
Expand All @@ -166,4 +166,9 @@ def get_activation(act_name: str) -> Callable:
if act_name.lower() not in act_func_dict:
raise ValueError(f"act_name({act_name}) not found in act_func_dict")

return act_func_dict[act_name.lower()]
act_layer = act_func_dict[act_name.lower()]
if isinstance(act_layer, type) and act_name != "stan":
# Is a activation class but not a instance of it, instantiate manually(except for 'Stan')
return act_layer()

return act_layer
5 changes: 4 additions & 1 deletion ppsci/utils/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
sp.Max: paddle.maximum,
sp.Min: paddle.minimum,
sp.Abs: paddle.abs,
sp.Heaviside: functools.partial(paddle.heaviside, y=paddle.zeros([])),
sp.Heaviside: paddle.heaviside,
sp.sign: paddle.sign,
sp.ceiling: paddle.ceil,
sp.floor: paddle.floor,
Expand Down Expand Up @@ -214,6 +214,9 @@ def __init__(
elif self.expr.func == sp.Heaviside:
self._apply_func = self._heaviside_operator_func
self._auxiliary_func = SYMPY_TO_PADDLE[sp.Heaviside]
self._auxiliary_func = functools.partial(
self._auxiliary_func, y=paddle.zeros([])
)
elif self.expr.func == sp.Min:
self._apply_func = self._minimum_operator_func
elif self.expr.func == sp.Max:
Expand Down