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
84c5fcd3
Commit
84c5fcd3
authored
Sep 18, 2020
by
Hongkun Yu
Committed by
A. Unique TensorFlower
Sep 18, 2020
Browse files
Use self.get_temp_dir and simplify the test
PiperOrigin-RevId: 332512380
parent
02275d26
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
16 deletions
+5
-16
official/nlp/modeling/layers/tn_expand_condense_test.py
official/nlp/modeling/layers/tn_expand_condense_test.py
+5
-16
No files found.
official/nlp/modeling/layers/tn_expand_condense_test.py
View file @
84c5fcd3
...
...
@@ -15,7 +15,6 @@
"""Tests for ExpandCondense tensor network layer."""
import
os
import
shutil
from
absl.testing
import
parameterized
import
numpy
as
np
...
...
@@ -166,20 +165,10 @@ class TNLayerTest(tf.test.TestCase, parameterized.TestCase):
# Train the model for 5 epochs
model
.
fit
(
data
,
self
.
labels
,
epochs
=
5
,
batch_size
=
32
)
for
save_path
in
[
'/test_model'
,
'/test_model.h5'
]:
# Save model to a SavedModel folder or h5 file, then load model
save_path
=
os
.
environ
[
'TEST_UNDECLARED_OUTPUTS_DIR'
]
+
save_path
save_path
=
os
.
path
.
join
(
self
.
get_temp_dir
(),
'test_model'
)
model
.
save
(
save_path
)
loaded_model
=
tf
.
keras
.
models
.
load_model
(
save_path
)
# Clean up SavedModel folder
if
os
.
path
.
isdir
(
save_path
):
shutil
.
rmtree
(
save_path
)
# Clean up h5 file
if
os
.
path
.
exists
(
save_path
):
os
.
remove
(
save_path
)
# Compare model predictions and loaded_model predictions
self
.
assertAllEqual
(
model
.
predict
(
data
),
loaded_model
.
predict
(
data
))
...
...
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