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
4b46ab20
Commit
4b46ab20
authored
Jun 30, 2020
by
Hongkun Yu
Committed by
A. Unique TensorFlower
Jun 30, 2020
Browse files
Internal change
PiperOrigin-RevId: 319114361
parent
3300fa04
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
official/nlp/tasks/question_answering.py
official/nlp/tasks/question_answering.py
+1
-1
official/nlp/tasks/sentence_prediction.py
official/nlp/tasks/sentence_prediction.py
+10
-6
No files found.
official/nlp/tasks/question_answering.py
View file @
4b46ab20
...
@@ -280,7 +280,7 @@ class QuestionAnsweringTask(base_task.Task):
...
@@ -280,7 +280,7 @@ class QuestionAnsweringTask(base_task.Task):
return
return
ckpt
=
tf
.
train
.
Checkpoint
(
**
model
.
checkpoint_items
)
ckpt
=
tf
.
train
.
Checkpoint
(
**
model
.
checkpoint_items
)
status
=
ckpt
.
re
store
(
ckpt_dir_or_file
)
status
=
ckpt
.
re
ad
(
ckpt_dir_or_file
)
status
.
expect_partial
().
assert_existing_objects_matched
()
status
.
expect_partial
().
assert_existing_objects_matched
()
logging
.
info
(
'finished loading pretrained checkpoint from %s'
,
logging
.
info
(
'finished loading pretrained checkpoint from %s'
,
ckpt_dir_or_file
)
ckpt_dir_or_file
)
official/nlp/tasks/sentence_prediction.py
View file @
4b46ab20
...
@@ -35,6 +35,7 @@ class SentencePredictionConfig(cfg.TaskConfig):
...
@@ -35,6 +35,7 @@ class SentencePredictionConfig(cfg.TaskConfig):
# At most one of `init_checkpoint` and `hub_module_url` can
# At most one of `init_checkpoint` and `hub_module_url` can
# be specified.
# be specified.
init_checkpoint
:
str
=
''
init_checkpoint
:
str
=
''
init_cls_pooler
:
bool
=
False
hub_module_url
:
str
=
''
hub_module_url
:
str
=
''
metric_type
:
str
=
'accuracy'
metric_type
:
str
=
'accuracy'
model
:
bert
.
BertPretrainerConfig
=
bert
.
BertPretrainerConfig
(
model
:
bert
.
BertPretrainerConfig
=
bert
.
BertPretrainerConfig
(
...
@@ -58,7 +59,7 @@ class SentencePredictionTask(base_task.Task):
...
@@ -58,7 +59,7 @@ class SentencePredictionTask(base_task.Task):
super
(
SentencePredictionTask
,
self
).
__init__
(
params
)
super
(
SentencePredictionTask
,
self
).
__init__
(
params
)
if
params
.
hub_module_url
and
params
.
init_checkpoint
:
if
params
.
hub_module_url
and
params
.
init_checkpoint
:
raise
ValueError
(
'At most one of `hub_module_url` and '
raise
ValueError
(
'At most one of `hub_module_url` and '
'`
pretra
in_checkpoint
_dir
` can be specified.'
)
'`in
it
_checkpoint` can be specified.'
)
if
params
.
hub_module_url
:
if
params
.
hub_module_url
:
self
.
_hub_module
=
hub
.
load
(
params
.
hub_module_url
)
self
.
_hub_module
=
hub
.
load
(
params
.
hub_module_url
)
else
:
else
:
...
@@ -178,13 +179,16 @@ class SentencePredictionTask(base_task.Task):
...
@@ -178,13 +179,16 @@ class SentencePredictionTask(base_task.Task):
return
return
pretrain2finetune_mapping
=
{
pretrain2finetune_mapping
=
{
'encoder'
:
'encoder'
:
model
.
checkpoint_items
[
'encoder'
],
model
.
checkpoint_items
[
'encoder'
],
'next_sentence.pooler_dense'
:
model
.
checkpoint_items
[
'sentence_prediction.pooler_dense'
],
}
}
# TODO(b/160251903): Investigate why no pooler dense improves finetuning
# accuracies.
if
self
.
task_config
.
init_cls_pooler
:
pretrain2finetune_mapping
[
'next_sentence.pooler_dense'
]
=
model
.
checkpoint_items
[
'sentence_prediction.pooler_dense'
]
ckpt
=
tf
.
train
.
Checkpoint
(
**
pretrain2finetune_mapping
)
ckpt
=
tf
.
train
.
Checkpoint
(
**
pretrain2finetune_mapping
)
status
=
ckpt
.
re
store
(
ckpt_dir_or_file
)
status
=
ckpt
.
re
ad
(
ckpt_dir_or_file
)
status
.
expect_partial
().
assert_existing_objects_matched
()
status
.
expect_partial
().
assert_existing_objects_matched
()
logging
.
info
(
'finished loading pretrained checkpoint from %s'
,
logging
.
info
(
'finished loading pretrained checkpoint from %s'
,
ckpt_dir_or_file
)
ckpt_dir_or_file
)
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