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
fd72a90e
Commit
fd72a90e
authored
Feb 03, 2020
by
Hongkun Yu
Committed by
A. Unique TensorFlower
Feb 03, 2020
Browse files
Adds transformer_layers properties
PiperOrigin-RevId: 293081282
parent
458ea726
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
official/nlp/modeling/networks/transformer_encoder.py
official/nlp/modeling/networks/transformer_encoder.py
+7
-0
No files found.
official/nlp/modeling/networks/transformer_encoder.py
View file @
fd72a90e
...
...
@@ -143,6 +143,7 @@ class TransformerEncoder(network.Network):
if
float_dtype
==
'float16'
:
embeddings
=
tf
.
cast
(
embeddings
,
tf
.
float16
)
self
.
_transformer_layers
=
[]
data
=
embeddings
attention_mask
=
layers
.
SelfAttentionMask
()([
data
,
mask
])
for
i
in
range
(
num_layers
):
...
...
@@ -155,6 +156,7 @@ class TransformerEncoder(network.Network):
kernel_initializer
=
initializer
,
dtype
=
float_dtype
,
name
=
'transformer/layer_%d'
%
i
)
self
.
_transformer_layers
.
append
(
layer
)
data
=
layer
([
data
,
attention_mask
])
first_token_tensor
=
(
...
...
@@ -178,6 +180,11 @@ class TransformerEncoder(network.Network):
def
get_config
(
self
):
return
self
.
_config_dict
@
property
def
transformer_layers
(
self
):
"""List of Transformer layers in the encoder."""
return
self
.
_transformer_layers
@
classmethod
def
from_config
(
cls
,
config
,
custom_objects
=
None
):
return
cls
(
**
config
)
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