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
4e434726
Commit
4e434726
authored
Apr 18, 2020
by
Chen Chen
Committed by
A. Unique TensorFlower
Apr 18, 2020
Browse files
Internal Change
PiperOrigin-RevId: 307233807
parent
c3b4ffc5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
official/nlp/bert/input_pipeline.py
official/nlp/bert/input_pipeline.py
+7
-2
No files found.
official/nlp/bert/input_pipeline.py
View file @
4e434726
...
@@ -60,7 +60,8 @@ def create_pretrain_dataset(input_patterns,
...
@@ -60,7 +60,8 @@ def create_pretrain_dataset(input_patterns,
batch_size
,
batch_size
,
is_training
=
True
,
is_training
=
True
,
input_pipeline_context
=
None
,
input_pipeline_context
=
None
,
use_next_sentence_label
=
True
):
use_next_sentence_label
=
True
,
use_position_id
=
False
):
"""Creates input dataset from (tf)records files for pretraining."""
"""Creates input dataset from (tf)records files for pretraining."""
name_to_features
=
{
name_to_features
=
{
'input_ids'
:
'input_ids'
:
...
@@ -79,7 +80,9 @@ def create_pretrain_dataset(input_patterns,
...
@@ -79,7 +80,9 @@ def create_pretrain_dataset(input_patterns,
if
use_next_sentence_label
:
if
use_next_sentence_label
:
name_to_features
[
'next_sentence_labels'
]
=
tf
.
io
.
FixedLenFeature
([
1
],
name_to_features
[
'next_sentence_labels'
]
=
tf
.
io
.
FixedLenFeature
([
1
],
tf
.
int64
)
tf
.
int64
)
if
use_position_id
:
name_to_features
[
'position_ids'
]
=
tf
.
io
.
FixedLenFeature
([
seq_length
],
tf
.
int64
)
for
input_pattern
in
input_patterns
:
for
input_pattern
in
input_patterns
:
if
not
tf
.
io
.
gfile
.
glob
(
input_pattern
):
if
not
tf
.
io
.
gfile
.
glob
(
input_pattern
):
raise
ValueError
(
'%s does not match any files.'
%
input_pattern
)
raise
ValueError
(
'%s does not match any files.'
%
input_pattern
)
...
@@ -123,6 +126,8 @@ def create_pretrain_dataset(input_patterns,
...
@@ -123,6 +126,8 @@ def create_pretrain_dataset(input_patterns,
}
}
if
use_next_sentence_label
:
if
use_next_sentence_label
:
x
[
'next_sentence_labels'
]
=
record
[
'next_sentence_labels'
]
x
[
'next_sentence_labels'
]
=
record
[
'next_sentence_labels'
]
if
use_position_id
:
x
[
'position_ids'
]
=
record
[
'position_ids'
]
y
=
record
[
'masked_lm_weights'
]
y
=
record
[
'masked_lm_weights'
]
...
...
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