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
fab3b518
Unverified
Commit
fab3b518
authored
Dec 08, 2021
by
ZOHETH
Committed by
GitHub
Dec 08, 2021
Browse files
fix deprecated tf method (#14671)
tf.matrix_band_part -> tf.linalg.band_part
parent
65b20b73
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
src/transformers/models/xlnet/modeling_tf_xlnet.py
src/transformers/models/xlnet/modeling_tf_xlnet.py
+3
-3
No files found.
src/transformers/models/xlnet/modeling_tf_xlnet.py
View file @
fab3b518
...
@@ -497,12 +497,12 @@ class TFXLNetMainLayer(tf.keras.layers.Layer):
...
@@ -497,12 +497,12 @@ class TFXLNetMainLayer(tf.keras.layers.Layer):
"""
"""
attn_mask
=
tf
.
ones
([
qlen
,
qlen
])
attn_mask
=
tf
.
ones
([
qlen
,
qlen
])
mask_u
=
tf
.
matrix_
band_part
(
attn_mask
,
0
,
-
1
)
mask_u
=
tf
.
linalg
.
band_part
(
attn_mask
,
0
,
-
1
)
mask_dia
=
tf
.
matrix_
band_part
(
attn_mask
,
0
,
0
)
mask_dia
=
tf
.
linalg
.
band_part
(
attn_mask
,
0
,
0
)
attn_mask_pad
=
tf
.
zeros
([
qlen
,
mlen
])
attn_mask_pad
=
tf
.
zeros
([
qlen
,
mlen
])
ret
=
tf
.
concat
([
attn_mask_pad
,
mask_u
-
mask_dia
],
1
)
ret
=
tf
.
concat
([
attn_mask_pad
,
mask_u
-
mask_dia
],
1
)
if
self
.
same_length
:
if
self
.
same_length
:
mask_l
=
tf
.
matrix_
band_part
(
attn_mask
,
-
1
,
0
)
mask_l
=
tf
.
linalg
.
band_part
(
attn_mask
,
-
1
,
0
)
ret
=
tf
.
concat
([
ret
[:,
:
qlen
]
+
mask_l
-
mask_dia
,
ret
[:,
qlen
:]],
1
)
ret
=
tf
.
concat
([
ret
[:,
:
qlen
]
+
mask_l
-
mask_dia
,
ret
[:,
qlen
:]],
1
)
return
ret
return
ret
...
...
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