-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes for CoCa cascaded attention poolers (#518)
Summary: A couple fixes to CoCa's attention pooling as pointed out in #517. Specifically, we need to change the input dim for the contrastive pooler to match the output dim from the captioning pooler in the case of cascaded attention pooling. We should also set `n_queries=1` for the contrastive pooler so that the pooled embeddings can be directly fed into contrastive loss (after appropriate normalization). Pull Request resolved: #518 Test Plan: ``` from torchmultimodal.models.coca.coca_model import coca_vit_l_14 model = coca_vit_l_14() bs, c, h, w, seq_len, vocab_size = 2, 3, 224, 224, 77, 49408 images = torch.randn(bs, c, h, w) texts = torch.randint(0, vocab_size, (bs, seq_len)) out = model(images, texts) print(out.image_pooled_output.shape, out.multimodal_embeddings.shape) ... torch.Size([2, 1, 768]) torch.Size([2, 76, 49408]) ``` Add new unit test: ``` python -m pytest -v tests/models/coca/test_coca_model.py ... ===== 4 passed in 3.18s ====== ``` Reviewed By: pbontrager Differential Revision: D52523771 Pulled By: ebsmothers fbshipit-source-id: 7c0197605e478ae6e3204f1ec0ab2e6adbf2377e
- Loading branch information
1 parent
fc92cea
commit 63c629a
Showing
2 changed files
with
61 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters