Coder Social home page Coder Social logo

Comments (7)

dbolya avatar dbolya commented on September 17, 2024

/tome/patch/timm.py contains no mention of "drop_path_rate". Did you edit the code?

from tome.

kos94ok avatar kos94ok commented on September 17, 2024

/tome/patch/timm.py contains no mention of "drop_path_rate". Did you edit the code?

File "/content/tome/tome/patch/timm.py", line 33, in forward x = x + self.drop_path(x_attn) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1208, in __getattr__ type(self).__name__, name)) AttributeError: 'ToMeBlock' object has no attribute 'drop_path'

from tome.

dbolya avatar dbolya commented on September 17, 2024

drop_path should exist in timm 0.4.12: https://github.com/rwightman/pytorch-image-models/blob/7096b52a613eefb4f6d8107366611c8983478b19/timm/models/vision_transformer.py#L207

Are you using the right version of timm (0.4.12) and passing in a timm model?

from tome.

dbolya avatar dbolya commented on September 17, 2024

Alternatively, you can replace drop_path with an identity since that's only necessary during training.

from tome.

kos94ok avatar kos94ok commented on September 17, 2024

drop_path should exist in timm 0.4.12: https://github.com/rwightman/pytorch-image-models/blob/7096b52a613eefb4f6d8107366611c8983478b19/timm/models/vision_transformer.py#L207

Are you using the right version of timm (0.4.12) and passing in a timm model?

I use timm==0.6.11

My code:

...

class Encoder(VisionTransformer):

    def __init__(self, img_size=224, patch_size=16, in_chans=3, embed_dim=768, depth=12, num_heads=12, mlp_ratio=4.,
             qkv_bias=True, drop_rate=0., attn_drop_rate=0., drop_path_rate=0., embed_layer=PatchEmbed):
    super().__init__(img_size, patch_size, in_chans, embed_dim=embed_dim, depth=depth, num_heads=num_heads,
                     mlp_ratio=mlp_ratio, qkv_bias=qkv_bias, drop_rate=drop_rate, attn_drop_rate=attn_drop_rate,
                     drop_path_rate=drop_path_rate, embed_layer=embed_layer,
                     num_classes=0, global_pool='', class_token=False)  # these disable the classifier head

    def forward(self, x):
        # Return all tokens
        return self.forward_features(x)
...

self.encoder = Encoder(img_size, patch_size, embed_dim=embed_dim, depth=enc_depth, num_heads=enc_num_heads,
                           mlp_ratio=enc_mlp_ratio)
tome.patch.timm(self.encoder, prop_attn=False)
self.encoder.r = 16

...

from tome.

dbolya avatar dbolya commented on September 17, 2024

Ah, we don't yet support higher versions of timm so you'll have to install 0.4.12.

from tome.

kos94ok avatar kos94ok commented on September 17, 2024

Ah, we don't yet support higher versions of timm so you'll have to install 0.4.12.

I think I solved it

timm==0.6.11

I replace (tome/tome/patch/timm.py)

x = x + self.drop_path(x_attn)
x = x + self.drop_path(self.mlp(self.norm2(x)))

to

x = x + self.drop_path1(x_attn)
x = x + self.drop_path1(self.mlp(self.norm2(x)))

from tome.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.