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
31ce1788
Commit
31ce1788
authored
Oct 25, 2021
by
A. Unique TensorFlower
Browse files
Internal change
PiperOrigin-RevId: 405501883
parent
26d8e705
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
16 deletions
+9
-16
official/projects/edgetpu/nlp/mobilebert_edgetpu_trainer_test.py
...l/projects/edgetpu/nlp/mobilebert_edgetpu_trainer_test.py
+1
-3
official/projects/edgetpu/nlp/serving/export_tflite_squad.py
official/projects/edgetpu/nlp/serving/export_tflite_squad.py
+1
-1
official/projects/edgetpu/nlp/utils/utils_test.py
official/projects/edgetpu/nlp/utils/utils_test.py
+7
-12
No files found.
official/projects/edgetpu/nlp/mobilebert_edgetpu_trainer_test.py
View file @
31ce1788
...
...
@@ -45,9 +45,7 @@ class EdgetpuBertTrainerTest(tf.test.TestCase):
def
setUp
(
self
):
super
(
EdgetpuBertTrainerTest
,
self
).
setUp
()
config_path
=
'third_party/tensorflow_models/official/projects/edgetpu/nlp/experiments/mobilebert_edgetpu_m.yaml'
self
.
experiment_params
=
params
.
EdgeTPUBERTCustomParams
.
from_yaml
(
config_path
)
self
.
experiment_params
=
params
.
EdgeTPUBERTCustomParams
()
self
.
strategy
=
tf
.
distribute
.
get_strategy
()
self
.
experiment_params
.
train_datasest
.
input_path
=
'dummy'
self
.
experiment_params
.
eval_dataset
.
input_path
=
'dummy'
...
...
official/projects/edgetpu/nlp/serving/export_tflite_squad.py
View file @
31ce1788
...
...
@@ -18,7 +18,7 @@ r"""Export tflite for MobileBERT-EdgeTPU with SQUAD head.
Example usage:
python3 export_tflite_squad.py \
--config_file=
third_party/tensorflow_models/
official/projects/edgetpu/nlp/experiments/mobilebert_edgetpu_xs.yaml \
--config_file=official/projects/edgetpu/nlp/experiments/mobilebert_edgetpu_xs.yaml \
--export_path=/tmp/ \
--quantization_method=full-integer
"""
...
...
official/projects/edgetpu/nlp/utils/utils_test.py
View file @
31ce1788
...
...
@@ -16,7 +16,6 @@
from
absl
import
flags
import
tensorflow
as
tf
import
yaml
from
official.projects.edgetpu.nlp.configs
import
params
from
official.projects.edgetpu.nlp.modeling
import
model_builder
...
...
@@ -48,25 +47,21 @@ class UtilsTest(tf.test.TestCase):
def
test_config_override
(
self
):
# Define several dummy flags which are call by the utils.config_override
# function.
file_path
=
'third_party/tensorflow_models/official/projects/edgetpu/nlp/experiments/mobilebert_edgetpu_m.yaml'
flags
.
DEFINE_string
(
'tpu'
,
None
,
'tpu_address.'
)
flags
.
DEFINE_list
(
'config_file'
,
[
file_path
],
flags
.
DEFINE_list
(
'config_file'
,
[],
'A list of config files path.'
)
flags
.
DEFINE_string
(
'params_override'
,
None
,
'Override params.'
)
flags
.
DEFINE_string
(
'params_override'
,
'orbit_config.mode=eval'
,
'Override params.'
)
flags
.
DEFINE_string
(
'model_dir'
,
'/tmp/'
,
'Model saving directory.'
)
flags
.
DEFINE_list
(
'mode'
,
[
'train'
],
'Job mode.'
)
flags
.
DEFINE_bool
(
'use_vizier'
,
False
,
'Whether to enable vizier based hyperparameter search.'
)
experiment_params
=
params
.
EdgeTPUBERTCustomParams
()
# By default, the orbit is set with train mode.
self
.
assertEqual
(
experiment_params
.
orbit_config
.
mode
,
'train'
)
# Config override should set the orbit to eval mode.
experiment_params
=
utils
.
config_override
(
experiment_params
,
FLAGS
)
experiment_params_dict
=
experiment_params
.
as_dict
()
with
tf
.
io
.
gfile
.
GFile
(
file_path
,
'r'
)
as
f
:
loaded_dict
=
yaml
.
load
(
f
,
Loader
=
yaml
.
FullLoader
)
# experiment_params contains all the configs but the loaded_dict might
# only contains partial of the configs.
self
.
assertTrue
(
nested_dict_compare
(
loaded_dict
,
experiment_params_dict
))
self
.
assertEqual
(
experiment_params
.
orbit_config
.
mode
,
'eval'
)
def
test_load_checkpoint
(
self
):
"""Test the pretrained model can be successfully loaded."""
...
...
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