MCPcopy Create free account
hub / github.com/RolnickLab/climart / __init__

Method __init__

climart/models/modules/mlp.py:72–92  ·  view source on GitHub ↗
(self,
                 in_dim: int,
                 out_dim: int,
                 net_norm: str = 'none',
                 activation_function: str = 'Gelu',
                 dropout: float = 0.0,
                 residual: bool = False
                 )

Source from the content-addressed store, hash-verified

70
71class MLP_Block(nn.Module):
72 def __init__(self,
73 in_dim: int,
74 out_dim: int,
75 net_norm: str = 'none',
76 activation_function: str = 'Gelu',
77 dropout: float = 0.0,
78 residual: bool = False
79 ):
80 super().__init__()
81 layer = [nn.Linear(in_dim, out_dim, bias=net_norm != 'batch_norm')]
82 if net_norm != 'none':
83 layer += [get_normalization_layer(net_norm, out_dim)]
84 layer += [get_activation_function(activation_function, functional=False)]
85 if dropout > 0:
86 layer += [nn.Dropout(dropout)]
87 self.layer = nn.Sequential(*layer)
88 self.residual = residual
89 if in_dim != out_dim:
90 self.residual = False
91 elif residual:
92 print('MLP block with residual!')
93
94 def forward(self, X: Tensor) -> Tensor:
95 X_out = self.layer(X)

Callers

nothing calls this directly

Calls 3

get_normalization_layerFunction · 0.90
get_activation_functionFunction · 0.90
__init__Method · 0.45

Tested by

no test coverage detected