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
5983e3d2
Commit
5983e3d2
authored
Aug 02, 2021
by
A. Unique TensorFlower
Browse files
Internal change
PiperOrigin-RevId: 388356184
parent
56b5494d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
official/nlp/data/sentence_prediction_dataloader.py
official/nlp/data/sentence_prediction_dataloader.py
+8
-2
No files found.
official/nlp/data/sentence_prediction_dataloader.py
View file @
5983e3d2
...
@@ -44,6 +44,8 @@ class SentencePredictionDataConfig(cfg.DataConfig):
...
@@ -44,6 +44,8 @@ class SentencePredictionDataConfig(cfg.DataConfig):
# Maps the key in TfExample to feature name.
# Maps the key in TfExample to feature name.
# E.g 'label_ids' to 'next_sentence_labels'
# E.g 'label_ids' to 'next_sentence_labels'
label_name
:
Optional
[
Tuple
[
str
,
str
]]
=
None
label_name
:
Optional
[
Tuple
[
str
,
str
]]
=
None
# Either tfrecord, sstable, or recordio.
file_type
:
str
=
'tfrecord'
@
data_loader_factory
.
register_data_loader_cls
(
SentencePredictionDataConfig
)
@
data_loader_factory
.
register_data_loader_cls
(
SentencePredictionDataConfig
)
...
@@ -111,7 +113,10 @@ class SentencePredictionDataLoader(data_loader.DataLoader):
...
@@ -111,7 +113,10 @@ class SentencePredictionDataLoader(data_loader.DataLoader):
def
load
(
self
,
input_context
:
Optional
[
tf
.
distribute
.
InputContext
]
=
None
):
def
load
(
self
,
input_context
:
Optional
[
tf
.
distribute
.
InputContext
]
=
None
):
"""Returns a tf.dataset.Dataset."""
"""Returns a tf.dataset.Dataset."""
reader
=
input_reader
.
InputReader
(
reader
=
input_reader
.
InputReader
(
params
=
self
.
_params
,
decoder_fn
=
self
.
_decode
,
parser_fn
=
self
.
_parse
)
dataset_fn
=
dataset_fn
.
pick_dataset_fn
(
self
.
_params
.
file_type
),
params
=
self
.
_params
,
decoder_fn
=
self
.
_decode
,
parser_fn
=
self
.
_parse
)
return
reader
.
read
(
input_context
)
return
reader
.
read
(
input_context
)
...
@@ -168,7 +173,8 @@ class TextProcessor(tf.Module):
...
@@ -168,7 +173,8 @@ class TextProcessor(tf.Module):
vocab_file
=
vocab_file
,
lower_case
=
lower_case
)
vocab_file
=
vocab_file
,
lower_case
=
lower_case
)
elif
tokenization
==
'SentencePiece'
:
elif
tokenization
==
'SentencePiece'
:
self
.
_tokenizer
=
modeling
.
layers
.
SentencepieceTokenizer
(
self
.
_tokenizer
=
modeling
.
layers
.
SentencepieceTokenizer
(
model_file_path
=
vocab_file
,
lower_case
=
lower_case
,
model_file_path
=
vocab_file
,
lower_case
=
lower_case
,
strip_diacritics
=
True
)
# Strip diacritics to follow ALBERT model
strip_diacritics
=
True
)
# Strip diacritics to follow ALBERT model
else
:
else
:
raise
ValueError
(
'Unsupported tokenization: %s'
%
tokenization
)
raise
ValueError
(
'Unsupported tokenization: %s'
%
tokenization
)
...
...
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