MCPcopy Create free account
hub / github.com/LeapLabTHU/DAT / forward

Method forward

models/dat.py:133–159  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

131 self.drop_path.append(DropPath(drop_path_rate[i]) if drop_path_rate[i] > 0.0 else nn.Identity())
132
133 def forward(self, x):
134
135 x = self.proj(x)
136
137 for d in range(self.depths):
138
139 if self.use_lpu:
140 x0 = x
141 x = self.local_perception_units[d](x.contiguous())
142 x = x + x0
143
144 if self.stage_spec[d] == 'X':
145 x0 = x
146 x = self.attns[d](x)
147 x = self.mlps[d](self.ln_cnvnxt[str(d)](x))
148 x = self.drop_path[d](x) + x0
149 else:
150 x0 = x
151 x, pos, ref = self.attns[d](self.layer_norms[2 * d](x))
152 x = self.layer_scales[2 * d](x)
153 x = self.drop_path[d](x) + x0
154 x0 = x
155 x = self.mlps[d](self.layer_norms[2 * d + 1](x))
156 x = self.layer_scales[2 * d + 1](x)
157 x = self.drop_path[d](x) + x0
158
159 return x
160
161
162class DAT(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected