MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / get_act_layer

Function get_act_layer

monai/networks/layers/utils.py:53–73  ·  view source on GitHub ↗

Create an activation layer instance. For example, to create activation layers: .. code-block:: python from monai.networks.layers import get_act_layer s_layer = get_act_layer(name="swish") p_layer = get_act_layer(name=("prelu", {"num_parameters": 1, "init": 0.

(name: tuple | str)

Source from the content-addressed store, hash-verified

51
52
53def get_act_layer(name: tuple | str):
54 """
55 Create an activation layer instance.
56
57 For example, to create activation layers:
58
59 .. code-block:: python
60
61 from monai.networks.layers import get_act_layer
62
63 s_layer = get_act_layer(name="swish")
64 p_layer = get_act_layer(name=("prelu", {"num_parameters": 1, "init": 0.25}))
65
66 Args:
67 name: an activation type string or a tuple of type string and parameters.
68 """
69 if name == "":
70 return torch.nn.Identity()
71 act_name, act_args = split_args(name)
72 act_type = Act[act_name]
73 return act_type(**act_args)
74
75
76def get_dropout_layer(name: tuple | str | float | int, dropout_dim: int | None = 1):

Callers 15

__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls 1

split_argsFunction · 0.90

Tested by 1

test_act_layerMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…