Comments (5)
if self.offset_range_factor > 0:
offset_range = torch.tensor([1.0 / Hk, 1.0 / Wk], device=device).reshape(1, 2, 1, 1)
offset = offset.tanh().mul(offset_range).mul(self.offset_range_factor)
offset = einops.rearrange(offset, "b p h w -> b h w p")
reference = self._get_ref_points(Hk, Wk, B, dtype, device) # B H W 2
if self.no_off:
offset = offset.fill(0.0)
if self.offset_range_factor >= 0:
pos = offset + reference
else:
pos = (offset + reference).tanh()
if self.offset_range_factor >= 0
:
reference: [0.5, H-0.5] -> [0.5/H, 1-0.5/H] -> [1/H, 2-1/H] -> [1/H-1, 1-1/H]
offset: [-1, 1] -> [-1/H,1/H] -> [-s/H, s/H]
(s=self.offset_range_factor
)
offset + reference: [-(1-1/H)-s/H, 1-1/H+s/H]
from dat.
I mean why? why not just [1/H, 1/H]? why offset_range_factor will work better? Maybe some exp?
from dat.
Update:
if self.offset_range_factor > 0:
offset_range = torch.tensor([1.0 / Hk, 1.0 / Wk], device=device).reshape(1, 2, 1, 1)
offset = offset.tanh().mul(offset_range).mul(self.offset_range_factor)
offset = einops.rearrange(offset, "b p h w -> b h w p")
reference = self._get_ref_points(Hk, Wk, B, dtype, device) # B H W 2
if self.no_off:
offset = offset.fill(0.0)
if self.offset_range_factor >= 0:
pos = offset + reference
else:
pos = (offset + reference).tanh()
if self.offset_range_factor >= 0
:
- reference: Get the normalized base coordinate grid.
- offset:
[-1, 1] -> [-1/H,1/H] -> [-s/H, s/H]
(s=self.offset_range_factor
) Here, the offset is a relative offset from the pixel position and1/H
is the unit offset on the H-axis (up or down). Similarly,1/W
is the unit offset on the W-axis (left or right). Specifying different unit offsets ensures thats
has the same units in different axes. - offset + reference: This results in sample positions corresponding to different reference positions after the relative offset is applied.
from dat.
The reference points are set to a uniform grid from 0.5 to -0.5 in size. The .mul_(2).sub_(1)
operation normalizes the coordinates into [-1,+1] to meet the protocol of the grid sampling operation F.grid_sample
in PyTorch, where (-1, -1) denotes the top-left corner and (+1, +1) denotes the bottom-right corner. The experiments on ablating offset range factor s
are in the ablation study sections in the paper.
from dat.
Happen to find this problem when I have the same question, so in the paper
And also there are actually ablation studies on page 8.
from dat.
Related Issues (20)
- how to visualize Figure 5,Figure 6, Figure7 HOT 3
- The computational cost of deformabel attention HOT 2
- some questions about the reference points and offset network HOT 1
- what's the difference between DAT and deformable DETR's attention? HOT 3
- Changing model input size from 384 -> 1024 HOT 2
- About Low Accuracy HOT 1
- Deformable Attention Journal Paper not referenced
- 训练时计算维度出错 HOT 1
- Which version of imagenet are you using? Is it ILSVRC 2012? HOT 1
- Face negative dimension issue when running on CIFAR10 HOT 1
- evaluate.sh: line 6: path-to-imagenet: No such file or directory HOT 1
- Controlling the number of keys per query HOT 1
- an unused parameters for class TransformerStage:"ns_per_pt" and "sr_ratio" HOT 1
- how to visual the Receptive Field like the figure 1 in the paper ? HOT 1
- 您好,DAT可以当作即插即用的模块吗 HOT 1
- How to run the model HOT 1
- About the range of offset HOT 1
- 处理文本数据或一维序列数据 HOT 1
- 采样点个数问题
- How can i get the most important keys in visualizations?
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 dat.