Comments (12)
@szxuhongye also, can you give the full trace?
torch 1.13.1 and the following is the full trace:
Traceback (most recent call last):
File "playground.py", line 39, in
loss = coca(
File "/home/usr/anaconda3/envs/coca/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/home/usr/anaconda3/envs/coca/lib/python3.8/site-packages/coca_pytorch/coca_pytorch.py", line 433, in forward
image_embeds, image_tokens = self.embed_image(images=images, image_tokens=image_tokens)
File "/home/usr/anaconda3/envs/coca/lib/python3.8/site-packages/coca_pytorch/coca_pytorch.py", line 412, in embed_image
img_queries = self.img_attn_pool(img_queries, image_tokens)
File "/home/usr/anaconda3/envs/coca/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/home/usr/anaconda3/envs/coca/lib/python3.8/site-packages/coca_pytorch/coca_pytorch.py", line 245, in forward
context = self.context_norm(context)
File "/home/usr/anaconda3/envs/coca/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/home/usr/anaconda3/envs/coca/lib/python3.8/site-packages/coca_pytorch/coca_pytorch.py", line 25, in forward
return F.layer_norm(x, x.shape[-1:], self.gamma, self.beta)
File "/home/usr/anaconda3/envs/coca/lib/python3.8/site-packages/torch/nn/functional.py", line 2515, in layer_norm
return torch.layer_norm(input, normalized_shape, weight, bias, eps, torch.backends.cudnn.enabled)
RuntimeError: Expected weight to be of same shape as normalized_shape, but got weight of shape [1024] and normalized_shape = [1000]
from coca-pytorch.
does your image_dim on CoCa init match up with the dim of the vit?
from coca-pytorch.
could you post a simple reproducible script?
from coca-pytorch.
could you post a simple reproducible script?
I just ran the code that you provide in the README.md
import torch
from vit_pytorch.simple_vit_with_patch_dropout import SimpleViT
from vit_pytorch.extractor import Extractor
vit = SimpleViT(
image_size = 256,
patch_size = 32,
num_classes = 1000,
dim = 1024,
depth = 6,
heads = 16,
mlp_dim = 2048,
patch_dropout = 0.5 # https://arxiv.org/abs/2212.00794
)
vit = Extractor(vit, return_embeddings_only = True, detach = False)
from coca_pytorch.coca_pytorch import CoCa
coca = CoCa(
dim = 512, # model dimension
img_encoder = vit, # vision transformer - image encoder, returning image embeddings as (batch, seq, dim)
image_dim = 1024, # image embedding dimension, if not the same as model dimensions
num_tokens = 20000, # number of text tokens
unimodal_depth = 6, # depth of the unimodal transformer
multimodal_depth = 6, # depth of the multimodal transformer
dim_head = 64, # dimension per attention head
heads = 8, # number of attention heads
caption_loss_weight = 1., # weight on the autoregressive caption loss
contrastive_loss_weight = 1., # weight on the contrastive loss between image and text CLS embeddings
).cuda()
text = torch.randint(0, 20000, (4, 512)).cuda()
images = torch.randn(4, 3, 256, 256).cuda()
loss = coca(
text = text,
images = images,
return_loss = True # set this to True to get the full caption + contrastive loss
)
loss.backward()
from coca-pytorch.
@szxuhongye it runs for me
which version of coca-pytorch are you on? and are you on the latest vit-pytorch?
from coca-pytorch.
@szxuhongye it runs for me
which version of coca-pytorch are you on? and are you on the latest vit-pytorch?
coca-pytorch 0.07 and vit-pytorch 0.40.2
from coca-pytorch.
@szxuhongye hmm, that looks ok
which version of pytorch?
from coca-pytorch.
@szxuhongye also, can you give the full trace?
from coca-pytorch.
@szxuhongye i see, the Extractor may be broken in pytorch 1.13.1 and not returning the embeddings, and instead, returning the logits
from coca-pytorch.
@szxuhongye hmm no, it still works for me try running all the cells in that colab. it is also on pytorch 1.13.0
from coca-pytorch.
@szxuhongye hmm no, it still works for me try running all the cells in that colab. it is also on pytorch 1.13.0
It is truly wired that it works after I uninstall and reinstall the entire environment. Thank you for your response.
from coca-pytorch.
glad it is working now 😁
from coca-pytorch.
Related Issues (18)
- Maybe don't need this rearrange HOT 2
- Contrastive loss should be applied to L2-normed embeddings instead of layer normed? HOT 2
- LayerNorm after attentional_pooler HOT 1
- convolution encoder better result then vit HOT 13
- Residual connection misssing?
- register_buffer for masks and position encodings breaks DDP HOT 14
- pad_dim_to() is not implemented HOT 3
- Reproduce Problem HOT 2
- Any plan to share the pre-trained models? HOT 24
- contrastive_labels - dist batch size isn't correct
- Generating the caption of a given image HOT 2
- why train VIT visual encoder first? HOT 1
- Reproducing the results in the paper HOT 2
- Extractor in vit_pytorch will detach the tensor. HOT 2
- Do you plan to give the code for fine-tuning? HOT 4
- attn_mask HOT 3
- How to train the model using my own dataset? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coca-pytorch.