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
12405107
"git@developer.sourcefind.cn:hehl2/torchaudio.git" did not exist on "9c56d88df7c41ea4c3606678d6d3f429897d356d"
Commit
12405107
authored
Sep 09, 2020
by
Chen Chen
Committed by
A. Unique TensorFlower
Sep 09, 2020
Browse files
Internal Change
PiperOrigin-RevId: 330822629
parent
f1b9d43f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
official/nlp/bert/input_pipeline.py
official/nlp/bert/input_pipeline.py
+17
-0
No files found.
official/nlp/bert/input_pipeline.py
View file @
12405107
...
@@ -285,5 +285,22 @@ def create_retrieval_dataset(file_path,
...
@@ -285,5 +285,22 @@ def create_retrieval_dataset(file_path,
_select_data_from_record
,
_select_data_from_record
,
num_parallel_calls
=
tf
.
data
.
experimental
.
AUTOTUNE
)
num_parallel_calls
=
tf
.
data
.
experimental
.
AUTOTUNE
)
dataset
=
dataset
.
batch
(
batch_size
,
drop_remainder
=
False
)
dataset
=
dataset
.
batch
(
batch_size
,
drop_remainder
=
False
)
def
_pad_to_batch
(
x
,
y
):
cur_size
=
tf
.
shape
(
y
)[
0
]
pad_size
=
batch_size
-
cur_size
pad_ids
=
tf
.
zeros
(
shape
=
[
pad_size
,
seq_length
],
dtype
=
tf
.
int32
)
for
key
in
(
'input_word_ids'
,
'input_mask'
,
'input_type_ids'
):
x
[
key
]
=
tf
.
concat
([
x
[
key
],
pad_ids
],
axis
=
0
)
pad_labels
=
-
tf
.
ones
(
shape
=
[
pad_size
,
1
],
dtype
=
tf
.
int32
)
y
=
tf
.
concat
([
y
,
pad_labels
],
axis
=
0
)
return
x
,
y
dataset
=
dataset
.
map
(
_pad_to_batch
,
num_parallel_calls
=
tf
.
data
.
experimental
.
AUTOTUNE
)
dataset
=
dataset
.
prefetch
(
tf
.
data
.
experimental
.
AUTOTUNE
)
dataset
=
dataset
.
prefetch
(
tf
.
data
.
experimental
.
AUTOTUNE
)
return
dataset
return
dataset
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