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
b9e30b11
Commit
b9e30b11
authored
Dec 15, 2018
by
Shining Sun
Browse files
bug fix
parent
6b673d03
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
15 deletions
+18
-15
official/resnet/keras/keras_cifar_main.py
official/resnet/keras/keras_cifar_main.py
+3
-2
official/resnet/keras/keras_common.py
official/resnet/keras/keras_common.py
+2
-1
official/resnet/keras/keras_imagenet_main.py
official/resnet/keras/keras_imagenet_main.py
+13
-12
No files found.
official/resnet/keras/keras_cifar_main.py
View file @
b9e30b11
...
...
@@ -112,6 +112,7 @@ def run_cifar_with_keras(flags_obj):
Raises:
ValueError: If fp16 is passed as it is not currently supported.
"""
print
(
">>>>>>>>>>>>>>>>>>>>> eager: "
,
flags_obj
.
enable_eager
)
if
flags_obj
.
enable_eager
:
tf
.
enable_eager_execution
()
...
...
@@ -199,13 +200,13 @@ def run_cifar_with_keras(flags_obj):
verbose
=
1
)
print
(
'Test loss:'
,
eval_output
[
0
])
stats
=
keras_common
.
analyze_eval_result
(
eval_output
)
stats
=
keras_common
.
analyze_
fit_and_
eval_result
(
history
,
eval_output
)
return
stats
def
define_keras_cifar_flags
():
flags
.
DEFINE_boolean
(
name
=
'enable_eager'
,
default
=
Fals
e
,
help
=
'Enable eager?'
)
flags
.
DEFINE_boolean
(
name
=
'enable_eager'
,
default
=
Tru
e
,
help
=
'Enable eager?'
)
def
main
(
_
):
...
...
official/resnet/keras/keras_common.py
View file @
b9e30b11
...
...
@@ -138,6 +138,7 @@ def get_dist_strategy():
print
(
'Not using distribution strategies.'
)
strategy
=
None
else
:
print
(
">>>>>>>>>>>>>>>>>>strategy!!!!!!! "
,
FLAGS
.
num_gpus
)
strategy
=
distribution_utils
.
get_distribution_strategy
(
num_gpus
=
FLAGS
.
num_gpus
)
...
...
@@ -158,7 +159,7 @@ def get_fit_callbacks(learning_rate_schedule_fn):
return
time_callback
,
tensorboard_callback
,
lr_callback
def
analyze_eval_result
(
eval_output
):
def
analyze_
fit_and_
eval_result
(
history
,
eval_output
):
stats
=
{}
stats
[
'accuracy_top_1'
]
=
eval_output
[
1
]
stats
[
'eval_loss'
]
=
eval_output
[
0
]
...
...
official/resnet/keras/keras_imagenet_main.py
View file @
b9e30b11
...
...
@@ -178,23 +178,24 @@ def run_imagenet_with_keras(flags_obj):
num_eval_steps
=
(
imagenet_main
.
_NUM_IMAGES
[
'validation'
]
//
flags_obj
.
batch_size
)
model
.
fit
(
train_input_dataset
,
epochs
=
flags_obj
.
train_epochs
,
steps_per_epoch
=
steps_per_epoch
,
callbacks
=
[
time_callback
,
lr_callback
,
tensorboard_callback
],
validation_steps
=
num_eval_steps
,
validation_data
=
eval_input_dataset
,
verbose
=
1
)
history
=
model
.
fit
(
train_input_dataset
,
epochs
=
flags_obj
.
train_epochs
,
steps_per_epoch
=
steps_per_epoch
,
callbacks
=
[
time_callback
,
lr_callback
,
tensorboard_callback
],
validation_steps
=
num_eval_steps
,
validation_data
=
eval_input_dataset
,
verbose
=
1
)
eval_output
=
model
.
evaluate
(
eval_input_dataset
,
steps
=
num_eval_steps
,
verbose
=
1
)
print
(
'Test loss:'
,
eval_output
[
0
])
stats
=
keras_common
.
analyze_eval_result
(
eval_output
)
stats
=
keras_common
.
analyze_
fit_and_
eval_result
(
history
,
eval_output
)
return
stats
...
...
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