Git Product home page Git Product logo

Comments (2)

flow3rdown avatar flow3rdown commented on May 29, 2024

Thanks for your attention!

  1. prompt_guids is 4 * [bsz, 256, 2, 2]. Shouldn't the dimension of torch.cat(prompt_guids, dim=1) is [bsz, 1024, 2, 2], but it's [bsz, 3840, 2, 2] in fact.

Actually, prompt_guids is [[bsz, 256, 2, 2], [bsz, 512, 2, 2], [bsz, 1024, 2, 2], [bsz,2048, 2, 2]], so the dimension of concatenation is [bsz, 3840, 2, 2].

  1. What does this code do? Is it just calculating the k,v values of superimposing four resnet blocks onto that self-attention layer?
for i in range(4):
   key_val = key_val + torch.einsum('bg,blh->blh', prompt_gate[:, i].view(-1, 1), split_prompt_guids[I])

The goal of this code is to use the dynamic gates(prompt_gate) to aggregate hierarchical image features(split_prompt_guids) to obtain the visual prefix(key, values).

  1. Why choose 64?

We use bert-base-uncased as the PLM, which has 768 hidden size and 12 attention heads, so the size of each attention head is768 / 12 = 64.

  1. If I want to switch to roberta plm, where I need to modify?

You need to modify the source code modeling_roberta.py like models/modeling_bert.py. For example, set past_key_values_length=0 before embedding_output = self.embeddings(...). For other places that need to be modified, please refer to the content annotated with #add in models/modeling_bert.py.

from hvpnet.

257556227 avatar 257556227 commented on May 29, 2024

Thank you very much for your answer,
Wish you a happy life!

from hvpnet.

Related Issues (18)

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.