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
ModelZoo
ResNet50_tensorflow
Commits
81fd50d6
Commit
81fd50d6
authored
Jun 16, 2021
by
A. Unique TensorFlower
Browse files
Internal change
PiperOrigin-RevId: 379815593
parent
e39f2477
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
official/nlp/modeling/models/seq2seq_transformer.py
official/nlp/modeling/models/seq2seq_transformer.py
+3
-1
No files found.
official/nlp/modeling/models/seq2seq_transformer.py
View file @
81fd50d6
...
@@ -111,13 +111,15 @@ class Seq2SeqTransformer(tf.keras.Model):
...
@@ -111,13 +111,15 @@ class Seq2SeqTransformer(tf.keras.Model):
def
_embedding_linear
(
self
,
embedding_matrix
,
x
):
def
_embedding_linear
(
self
,
embedding_matrix
,
x
):
"""Uses embeddings as linear transformation weights."""
"""Uses embeddings as linear transformation weights."""
embedding_matrix
=
tf
.
cast
(
embedding_matrix
,
dtype
=
self
.
compute_dtype
)
x
=
tf
.
cast
(
x
,
dtype
=
self
.
compute_dtype
)
batch_size
=
tf
.
shape
(
x
)[
0
]
batch_size
=
tf
.
shape
(
x
)[
0
]
length
=
tf
.
shape
(
x
)[
1
]
length
=
tf
.
shape
(
x
)[
1
]
hidden_size
=
tf
.
shape
(
x
)[
2
]
hidden_size
=
tf
.
shape
(
x
)[
2
]
vocab_size
=
tf
.
shape
(
embedding_matrix
)[
0
]
vocab_size
=
tf
.
shape
(
embedding_matrix
)[
0
]
x
=
tf
.
reshape
(
x
,
[
-
1
,
hidden_size
])
x
=
tf
.
reshape
(
x
,
[
-
1
,
hidden_size
])
logits
=
tf
.
matmul
(
x
,
tf
.
cast
(
embedding_matrix
,
x
.
dtype
),
transpose_b
=
True
)
logits
=
tf
.
matmul
(
x
,
embedding_matrix
,
transpose_b
=
True
)
return
tf
.
reshape
(
logits
,
[
batch_size
,
length
,
vocab_size
])
return
tf
.
reshape
(
logits
,
[
batch_size
,
length
,
vocab_size
])
...
...
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