Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
8a0ed0a9
Unverified
Commit
8a0ed0a9
authored
Feb 15, 2024
by
amyeroberts
Committed by
GitHub
Feb 15, 2024
Browse files
Fix copies between DETR and DETA (#29037)
parent
5b6fa230
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
src/transformers/models/deta/modeling_deta.py
src/transformers/models/deta/modeling_deta.py
+2
-1
No files found.
src/transformers/models/deta/modeling_deta.py
View file @
8a0ed0a9
...
@@ -627,7 +627,8 @@ class DetaMultiscaleDeformableAttention(nn.Module):
...
@@ -627,7 +627,8 @@ class DetaMultiscaleDeformableAttention(nn.Module):
def
_reset_parameters
(
self
):
def
_reset_parameters
(
self
):
nn
.
init
.
constant_
(
self
.
sampling_offsets
.
weight
.
data
,
0.0
)
nn
.
init
.
constant_
(
self
.
sampling_offsets
.
weight
.
data
,
0.0
)
thetas
=
torch
.
arange
(
self
.
n_heads
,
dtype
=
torch
.
int64
).
float
()
*
(
2.0
*
math
.
pi
/
self
.
n_heads
)
default_dtype
=
torch
.
get_default_dtype
()
thetas
=
torch
.
arange
(
self
.
n_heads
,
dtype
=
torch
.
int64
).
to
(
default_dtype
)
*
(
2.0
*
math
.
pi
/
self
.
n_heads
)
grid_init
=
torch
.
stack
([
thetas
.
cos
(),
thetas
.
sin
()],
-
1
)
grid_init
=
torch
.
stack
([
thetas
.
cos
(),
thetas
.
sin
()],
-
1
)
grid_init
=
(
grid_init
=
(
(
grid_init
/
grid_init
.
abs
().
max
(
-
1
,
keepdim
=
True
)[
0
])
(
grid_init
/
grid_init
.
abs
().
max
(
-
1
,
keepdim
=
True
)[
0
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment