-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 |
pls help me! 555 thx!!
The text was updated successfully, but these errors were encountered: