"torchvision/csrc/io/image/cpu/readjpeg_impl.cpp" did not exist on "6afb3496cc27cebc938ac02880a35d6ddf9796a0"
Commit 0505b99c authored by Neal Wu's avatar Neal Wu Committed by GitHub
Browse files

Merge pull request #1127 from AsterAI/fix_cifar_logs

1. Little bit optimized code
parents f7ff5949 74ad728e
...@@ -52,6 +52,8 @@ tf.app.flags.DEFINE_integer('max_steps', 1000000, ...@@ -52,6 +52,8 @@ tf.app.flags.DEFINE_integer('max_steps', 1000000,
"""Number of batches to run.""") """Number of batches to run.""")
tf.app.flags.DEFINE_boolean('log_device_placement', False, tf.app.flags.DEFINE_boolean('log_device_placement', False,
"""Whether to log device placement.""") """Whether to log device placement.""")
tf.app.flags.DEFINE_integer('log_frequency', 10,
"""How often to log results to the console.""")
def train(): def train():
...@@ -78,19 +80,21 @@ def train(): ...@@ -78,19 +80,21 @@ def train():
def begin(self): def begin(self):
self._step = -1 self._step = -1
self._start_time = time.time()
def before_run(self, run_context): def before_run(self, run_context):
self._step += 1 self._step += 1
self._start_time = time.time()
return tf.train.SessionRunArgs(loss) # Asks for loss value. return tf.train.SessionRunArgs(loss) # Asks for loss value.
def after_run(self, run_context, run_values): def after_run(self, run_context, run_values):
duration = time.time() - self._start_time 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 loss_value = run_values.results
if self._step % 10 == 0: examples_per_sec = FLAGS.log_frequency * FLAGS.batch_size / duration
num_examples_per_step = FLAGS.batch_size sec_per_batch = float(duration / FLAGS.log_frequency)
examples_per_sec = num_examples_per_step / duration
sec_per_batch = float(duration)
format_str = ('%s: step %d, loss = %.2f (%.1f examples/sec; %.3f ' format_str = ('%s: step %d, loss = %.2f (%.1f examples/sec; %.3f '
'sec/batch)') 'sec/batch)')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment