MCPcopy Create free account
hub / github.com/OpenDriveLab/TCP / residual

Method residual

roach/models/torch_util.py:56–68  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

54 self.bn1 = nn.BatchNorm2d(self.inchan)
55
56 def residual(self, x):
57 # inplace should be False for the first relu, so that it does not change the input,
58 # which will be used for skip connection.
59 # getattr is for backwards compatibility with loaded models
60 if getattr(self, "batch_norm", False):
61 x = self.bn0(x)
62 x = F.relu(x, inplace=False)
63 x = self.conv0(x)
64 if getattr(self, "batch_norm", False):
65 x = self.bn1(x)
66 x = F.relu(x, inplace=True)
67 x = self.conv1(x)
68 return x
69
70 def forward(self, x):
71 return x + self.residual(x)

Callers 1

forwardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected