Giter Club home page Giter Club logo

Comments (4)

pengzhiliang avatar pengzhiliang commented on July 27, 2024 1

Yes, it is actually different.
The reason is that the network has no requirements in patch dimensions.
multi head self-attention only requires the size of Q, K, V needs consistency.
FFN only processes on C dimensions.
So, the encoder doesn't care about how many patches it accepts.

from mae-pytorch.

pengzhiliang avatar pengzhiliang commented on July 27, 2024

Hello, in the end-to-end fine-tuning stage, the encoder accepts the full set tokens of image without any masked token. In fact, pre-trained stage just provides a better init for fine-tuning. As you can find the difference in my code:

pre-train:

x = x + self.pos_embed.type_as(x).to(x.device).clone().detach()

B, _, C = x.shape
x_vis = x[~mask].reshape(B, -1, C) # ~mask means visible

for blk in self.blocks:
    x_vis = blk(x_vis)

fine-tune

if self.pos_embed is not None:
    x = x + self.pos_embed.expand(B, -1, -1).type_as(x).to(x.device).clone().detach()

for blk in self.blocks:
    x = blk(x)

Hope this can help you!

from mae-pytorch.

stephenllh avatar stephenllh commented on July 27, 2024

Thanks! I now have one more question: If we see Transformers for NLP, the sequence dimension is fixed to some arbitrary max_len hyperparameter. However, that is not the case here, where the number of tokens (sequence length) differs in pretraining and fine-tuning.

I wonder if this is due to the batch operation that requires every data in the dataloader to have the same sequence length, and less about the network constraint.

from mae-pytorch.

chokyungjin avatar chokyungjin commented on July 27, 2024

I have the same question.
In the case of pre-train, I know that only visible tokens (25% of the original image) in the encoder are input, but when fine-tuning, the model does not use a mask, so if the entire original image is input, isn't it a different size?

from mae-pytorch.

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.