MCPcopy Create free account
hub / github.com/TorchSSL/TorchSSL / __init__

Method __init__

models/nets/resnet50.py:24–49  ·  view source on GitHub ↗
(
            self,
            inplanes: int,
            planes: int,
            stride: int = 1,
            downsample: Optional[nn.Module] = None,
            groups: int = 1,
            base_width: int = 64,
            dilation: int = 1,
            norm_layer: Optional[Callable[..., nn.Module]] = None
    )

Source from the content-addressed store, hash-verified

22 expansion: int = 1
23
24 def __init__(
25 self,
26 inplanes: int,
27 planes: int,
28 stride: int = 1,
29 downsample: Optional[nn.Module] = None,
30 groups: int = 1,
31 base_width: int = 64,
32 dilation: int = 1,
33 norm_layer: Optional[Callable[..., nn.Module]] = None
34 ) -> None:
35 super(BasicBlock, self).__init__()
36 if norm_layer is None:
37 norm_layer = nn.BatchNorm2d
38 if groups != 1 or base_width != 64:
39 raise ValueError('BasicBlock only supports groups=1 and base_width=64')
40 if dilation > 1:
41 raise NotImplementedError("Dilation > 1 not supported in BasicBlock")
42 # Both self.conv1 and self.downsample layers downsample the input when stride != 1
43 self.conv1 = conv3x3(inplanes, planes, stride)
44 self.bn1 = norm_layer(planes)
45 self.relu = nn.ReLU(inplace=True)
46 self.conv2 = conv3x3(planes, planes)
47 self.bn2 = norm_layer(planes)
48 self.downsample = downsample
49 self.stride = stride
50
51 def forward(self, x: Tensor) -> Tensor:
52 identity = x

Callers

nothing calls this directly

Calls 2

conv3x3Function · 0.85
__init__Method · 0.45

Tested by

no test coverage detected