This repository has been archived by the owner on Jan 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
AttributeError: 'ToMeVisionTransformer' object has no attribute 'blocks' #40
Comments
Hello, I need more information than this. Can you share the snippet of code you're trying to run? |
Hi, sorry for the delay. Here's the answers to your questions as far as I can tell:
Thus, for the most basic ToMe, all you need to implement is this:
# localvit
def forward(self, x):
size = None
r = **** # Fill this in either at initialization or pull from something like `self.r`.
# Then pass these parameters into your blocks (through your stages, not pictured here)
for block in self.blocks:
x, size = block(x, size, r)
# myblock
def forward(self, size, r):
x = x + self.pos_embed(x)
xa, k = self.attn(self.norm1(x)) # Make sure your attn module returns the mean of k over the heads (e.g., k.mean(1))
x = x + self.drop_path(xa)
# Apply ToMe after attention
if r > 0:
merge, _ = bipartite_soft_matching(k, r) # Pass in class_token=True if your model has a class token
x, size = merge_wavg(merge, x, size)
# Rest of the block
****
return x, size One caveat is that ToMe expects the tensors x and k to have a shape |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
pls help me! 555 thx!!
The text was updated successfully, but these errors were encountered: