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

Method __init__

monai/networks/nets/hovernet.py:53–93  ·  view source on GitHub ↗

Args: num_features: number of internal channels used for the layer in_channels: number of the input channels. out_channels: number of the output channels. dropout_prob: dropout rate after each dense layer. act: activation type and

(
        self,
        num_features: int,
        in_channels: int,
        out_channels: int,
        dropout_prob: float = 0.0,
        act: str | tuple = ("relu", {"inplace": True}),
        norm: str | tuple = "batch",
        kernel_size: int = 3,
        padding: int = 0,
    )

Source from the content-addressed store, hash-verified

51class _DenseLayerDecoder(nn.Module):
52
53 def __init__(
54 self,
55 num_features: int,
56 in_channels: int,
57 out_channels: int,
58 dropout_prob: float = 0.0,
59 act: str | tuple = ("relu", {"inplace": True}),
60 norm: str | tuple = "batch",
61 kernel_size: int = 3,
62 padding: int = 0,
63 ) -> None:
64 """
65 Args:
66 num_features: number of internal channels used for the layer
67 in_channels: number of the input channels.
68 out_channels: number of the output channels.
69 dropout_prob: dropout rate after each dense layer.
70 act: activation type and arguments. Defaults to relu.
71 norm: feature normalization type and arguments. Defaults to batch norm.
72 kernel_size: size of the kernel for >1 convolutions (dependent on mode)
73 padding: padding value for >1 convolutions.
74 """
75 super().__init__()
76
77 conv_type: Callable = Conv[Conv.CONV, 2]
78 dropout_type: Callable = Dropout[Dropout.DROPOUT, 2]
79
80 self.layers = nn.Sequential()
81
82 self.layers.add_module("preact_bna/bn", get_norm_layer(name=norm, spatial_dims=2, channels=in_channels))
83 self.layers.add_module("preact_bna/relu", get_act_layer(name=act))
84 self.layers.add_module("conv1", conv_type(in_channels, num_features, kernel_size=1, bias=False))
85 self.layers.add_module("conv1/norm", get_norm_layer(name=norm, spatial_dims=2, channels=num_features))
86 self.layers.add_module("conv1/relu2", get_act_layer(name=act))
87 self.layers.add_module(
88 "conv2",
89 conv_type(num_features, out_channels, kernel_size=kernel_size, padding=padding, groups=4, bias=False),
90 )
91
92 if dropout_prob > 0:
93 self.layers.add_module("dropout", dropout_type(dropout_prob))
94
95 def forward(self, x: torch.Tensor) -> torch.Tensor:
96 x1 = self.layers(x)

Callers

nothing calls this directly

Calls 3

get_norm_layerFunction · 0.90
get_act_layerFunction · 0.90
__init__Method · 0.45

Tested by

no test coverage detected