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

Class Refine

monai/networks/blocks/fcn.py:60–94  ·  view source on GitHub ↗

Simple residual block to refine the details of the activation maps.

Source from the content-addressed store, hash-verified

58
59
60class Refine(nn.Module):
61 """
62 Simple residual block to refine the details of the activation maps.
63 """
64
65 def __init__(self, planes: int):
66 """
67 Args:
68 planes: number of input channels.
69 """
70 super().__init__()
71
72 relu_type: type[nn.ReLU] = Act[Act.RELU]
73 conv2d_type: type[nn.Conv2d] = Conv[Conv.CONV, 2]
74 norm2d_type: type[nn.BatchNorm2d] = Norm[Norm.BATCH, 2]
75
76 self.bn = norm2d_type(num_features=planes)
77 self.relu = relu_type(inplace=True)
78 self.conv1 = conv2d_type(in_channels=planes, out_channels=planes, kernel_size=3, padding=1)
79 self.conv2 = conv2d_type(in_channels=planes, out_channels=planes, kernel_size=3, padding=1)
80
81 def forward(self, x: torch.Tensor) -> torch.Tensor:
82 """
83 Args:
84 x: in shape (batch, planes, spatial_1, spatial_2).
85 """
86 residual = x
87 x = self.bn(x)
88 x = self.relu(x)
89 x = self.conv1(x)
90 x = self.bn(x)
91 x = self.relu(x)
92 x = self.conv2(x)
93
94 return residual + x
95
96
97class FCN(nn.Module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…