MCPcopy Create free account
hub / github.com/ImprintLab/Medical-SAM2 / __init__

Method __init__

sam2_train/modeling/sam2_utils.py:109–125  ·  view source on GitHub ↗
(
        self,
        input_dim: int,
        hidden_dim: int,
        output_dim: int,
        num_layers: int,
        activation: nn.Module = nn.ReLU,
        sigmoid_output: bool = False,
    )

Source from the content-addressed store, hash-verified

107# https://github.com/facebookresearch/MaskFormer/blob/main/mask_former/modeling/transformer/transformer_predictor.py # noqa
108class MLP(nn.Module):
109 def __init__(
110 self,
111 input_dim: int,
112 hidden_dim: int,
113 output_dim: int,
114 num_layers: int,
115 activation: nn.Module = nn.ReLU,
116 sigmoid_output: bool = False,
117 ) -> None:
118 super().__init__()
119 self.num_layers = num_layers
120 h = [hidden_dim] * (num_layers - 1)
121 self.layers = nn.ModuleList(
122 nn.Linear(n, k) for n, k in zip([input_dim] + h, h + [output_dim])
123 )
124 self.sigmoid_output = sigmoid_output
125 self.act = activation()
126
127 def forward(self, x):
128 for i, layer in enumerate(self.layers):

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected