Comments (8)
Yes, the tensor h_w has a shape of [1, bs, 2].
Did you delete the brackets of the tensor gaussian?
SMCA-DETR/models/transformer.py
Line 306 in e4df3ab
from smca-detr.
@hanqiu-hq Hi, the error not comes from transformer decoder, but from SMCA attention forward:
if naive:
attn_output_weights = torch.bmm(q, k.transpose(1, 2))
assert list(attn_output_weights.size()) == [
bsz * num_heads, tgt_len, src_len]
if attn_mask is not None:
if attn_mask.dtype == torch.bool:
attn_output_weights.masked_fill_(attn_mask, float('-inf'))
else:
attn_output_weights += attn_mask
if key_padding_mask is not None:
attn_output_weights = attn_output_weights.view(
bsz, num_heads, tgt_len, src_len)
attn_output_weights = attn_output_weights.masked_fill(
key_padding_mask.unsqueeze(1).unsqueeze(2), float('-inf'),)
attn_output_weights = attn_output_weights.view(
bsz * num_heads, tgt_len, src_len)
attn_output_weights = attn_output_weights + \
gaussian[0].permute(2, 0, 1)
SMCA-DETR/models/attention_layer.py
Line 264 in e4df3ab
which means gaussian[0] 's shape is not right, but tthis value how could it be wrong? images shape not problem, h_w no problem..
from smca-detr.
The gaussian tensor has three dimensions with the shape of [tgt_len, H*W, bs * num_head].
It is wrapped in a list when passing to the attention module.
SMCA-DETR/models/transformer.py
Line 306 in e4df3ab
So the gaussian[0] in the attention module should have the same shape and num of dimensions as above.
you can try to print the shape of "gaussian[0]" in the attention module.
SMCA-DETR/models/attention_layer.py
Line 264 in e4df3ab
from smca-detr.
@hanqiu-hq My guassian shape is:
gaussian shape: torch.Size([100, 962, 80, 2])
seems wrong, seems the last shape [80, 2] is not right? the 2 is reduandent, what caused this error?
from smca-detr.
@hanqiu-hq And I think , maybe h_w shape is not as you told.... every variable shape I logged:
point shape: torch.Size([100, 80, 2])
distance shape: torch.Size([100, 858, 80, 2])
gaussian shape 0: torch.Size([100, 858, 80, 2])
gaussian shape: torch.Size([100, 858, 80, 2])
point shape: torch.Size([100, 80, 2])
distance shape: torch.Size([100, 864, 80, 2])
gaussian shape 0: torch.Size([100, 864, 80, 2])
gaussian shape: torch.Size([100, 864, 80, 2])
start from point shape, it was wrong..
from the code:
if self.layer_index == 0:
point_sigmoid_ref_inter = self.point1(out)
point_sigmoid_ref = point_sigmoid_ref_inter.sigmoid()
point_sigmoid_ref = (h_w - 0) * point_sigmoid_ref / 32
point_sigmoid_ref = point_sigmoid_ref.repeat(1, 1, 8)
else:
point_sigmoid_ref = point_ref_previous
print('point_sigmoid_ref: ', point_sigmoid_ref.shape)
point = point_sigmoid_ref + point_sigmoid_offset
point = point.view(tgt_len, -1, 2)
distance = (point.unsqueeze(1) - grid.unsqueeze(0)).pow(2)
print('point shape: ', point.unsqueeze(1).shape)
print('grid shape: ', grid.unsqueeze(0).shape)
print('distance shape: ', distance.shape)
I can make sure, your code has problem. even grid shape is right
grid 0 shape: torch.Size([1092, 80, 2])
so which shape seems wrong here?
from smca-detr.
The last dimension of tensor distance with shape [2] is eliminated at:
SMCA-DETR/models/transformer.py
Line 292 in e4df3ab
So the tensor gaussian will have three dimensions with shape [tgt_len, HW, bs * num_head] instead of [tgt_len, HW, bs * num_head , 2].
Did you skip the code from L280-L298?
SMCA-DETR/models/transformer.py
Lines 280 to 298 in e4df3ab
from smca-detr.
@hanqiu-hq Holy shit... seems you set a value of a string to a default bool value....
What should I set here? type1 or type4?
from smca-detr.
@hanqiu-hq I started trained, the speed seems not very normal:
from smca-detr.
Related Issues (20)
- IndexError: list index out of range when running inference HOT 10
- Question about the FLOPs in Table 1 HOT 3
- pretrained model download link HOT 6
- Does SMCA used warmup? HOT 1
- OOM for ResNet50-DC5 even for 32GB GPUs HOT 11
- 40.38 AP for ResNet50 single level feature HOT 2
- Pre-trained Model on VG
- ACT module release? HOT 1
- How to use target GPU for training?
- How to use target GPU for training? HOT 2
- Training coco metrics seems to be good but when trained model validated using --eval mode, only garbage values are printed. HOT 3
- Searching for help about the visiulization image. HOT 4
- ACT model compute flops HOT 5
- Code for calculating Flops
- An error occurred while using ACT
- 请问能否开源ACT论文中Knowlwdge Disillation Loss相关代码
- what's the modification compare with original DETR HOT 4
- multiscale implementation HOT 2
- About input format HOT 20
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 smca-detr.