@staticmethod
PYL-R0201 954 view(x.shape[0], self.embed_dim, x_size[0], x_size[1]) # B Ph*Pw C
955 return x
956
957 def flops(self): 958 flops = 0
959 return flops
960
259
260 self.load_state_dict(self.state, strict=False)
261
262 def _init_weights(self, m): 263 if isinstance(m, nn.Linear):
264 nn.init.trunc_normal_(m.weight, std=.02)
265 if isinstance(m, nn.Linear) and m.bias is not None:
251
252 self.load_state_dict(self.state, strict=False)
253
254 def _init_weights(self, m): 255 if isinstance(m, nn.Linear):
256 nn.init.trunc_normal_(m.weight, std=.02)
257 if isinstance(m, nn.Linear) and m.bias is not None:
The method doesn't use its bound instance. Decorate this method with @staticmethod
decorator, so that Python does not have to instantiate a bound method for every instance of this class thereby saving memory and computation. Read more about staticmethods here.