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
0505b99c
Commit
0505b99c
authored
Mar 15, 2017
by
Neal Wu
Committed by
GitHub
Mar 15, 2017
Browse files
Merge pull request #1127 from AsterAI/fix_cifar_logs
1. Little bit optimized code
parents
f7ff5949
74ad728e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
tutorials/image/cifar10/cifar10_train.py
tutorials/image/cifar10/cifar10_train.py
+11
-7
No files found.
tutorials/image/cifar10/cifar10_train.py
View file @
0505b99c
...
...
@@ -52,6 +52,8 @@ tf.app.flags.DEFINE_integer('max_steps', 1000000,
"""Number of batches to run."""
)
tf
.
app
.
flags
.
DEFINE_boolean
(
'log_device_placement'
,
False
,
"""Whether to log device placement."""
)
tf
.
app
.
flags
.
DEFINE_integer
(
'log_frequency'
,
10
,
"""How often to log results to the console."""
)
def
train
():
...
...
@@ -78,19 +80,21 @@ def train():
def
begin
(
self
):
self
.
_step
=
-
1
self
.
_start_time
=
time
.
time
()
def
before_run
(
self
,
run_context
):
self
.
_step
+=
1
self
.
_start_time
=
time
.
time
()
return
tf
.
train
.
SessionRunArgs
(
loss
)
# Asks for loss value.
def
after_run
(
self
,
run_context
,
run_values
):
duration
=
time
.
time
()
-
self
.
_start_time
loss_value
=
run_values
.
results
if
self
.
_step
%
10
==
0
:
num_examples_per_step
=
FLAGS
.
batch_size
examples_per_sec
=
num_examples_per_step
/
duration
sec_per_batch
=
float
(
duration
)
if
self
.
_step
%
FLAGS
.
log_frequency
==
0
:
current_time
=
time
.
time
()
duration
=
current_time
-
self
.
_start_time
self
.
_start_time
=
current_time
loss_value
=
run_values
.
results
examples_per_sec
=
FLAGS
.
log_frequency
*
FLAGS
.
batch_size
/
duration
sec_per_batch
=
float
(
duration
/
FLAGS
.
log_frequency
)
format_str
=
(
'%s: step %d, loss = %.2f (%.1f examples/sec; %.3f '
'sec/batch)'
)
...
...
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