MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / update

Method update

tensorflow/python/keras/utils/generic_utils.py:352–476  ·  view source on GitHub ↗

Updates the progress bar. Arguments: current: Index of current step. values: List of tuples: `(name, value_for_last_step)`. If `name` is in `stateful_metrics`, `value_for_last_step` will be displayed as-is. Else, an average of the

(self, current, values=None)

Source from the content-addressed store, hash-verified

350 self._last_update = 0
351
352 def update(self, current, values=None):
353 """Updates the progress bar.
354
355 Arguments:
356 current: Index of current step.
357 values: List of tuples:
358 `(name, value_for_last_step)`.
359 If `name` is in `stateful_metrics`,
360 `value_for_last_step` will be displayed as-is.
361 Else, an average of the metric over time will be displayed.
362 """
363 values = values or []
364 for k, v in values:
365 if k not in self._values_order:
366 self._values_order.append(k)
367 if k not in self.stateful_metrics:
368 if k not in self._values:
369 self._values[k] = [v * (current - self._seen_so_far),
370 current - self._seen_so_far]
371 else:
372 self._values[k][0] += v * (current - self._seen_so_far)
373 self._values[k][1] += (current - self._seen_so_far)
374 else:
375 # Stateful metrics output a numeric value. This representation
376 # means "take an average from a single value" but keeps the
377 # numeric formatting.
378 self._values[k] = [v, 1]
379 self._seen_so_far = current
380
381 now = time.time()
382 info = ' - %.0fs' % (now - self._start)
383 if self.verbose == 1:
384 if (now - self._last_update < self.interval and
385 self.target is not None and current < self.target):
386 return
387
388 prev_total_width = self._total_width
389 if self._dynamic_display:
390 sys.stdout.write('\b' * prev_total_width)
391 sys.stdout.write('\r')
392 else:
393 sys.stdout.write('\n')
394
395 if self.target is not None:
396 numdigits = int(np.log10(self.target)) + 1
397 bar = ('%' + str(numdigits) + 'd/%d [') % (current, self.target)
398 prog = float(current) / self.target
399 prog_width = int(self.width * prog)
400 if prog_width > 0:
401 bar += ('=' * (prog_width - 1))
402 if current < self.target:
403 bar += '>'
404 else:
405 bar += '='
406 bar += ('.' * (self.width - prog_width))
407 bar += ']'
408 else:
409 bar = '%7d/Unknown' % current

Callers 15

addMethod · 0.95
_testCondMethod · 0.45
__init__Method · 0.45
test_function_basicsMethod · 0.45
_get_variablesFunction · 0.45
on_batch_endMethod · 0.45
on_epoch_endMethod · 0.45

Calls 7

timeMethod · 0.80
maxFunction · 0.50
absFunction · 0.50
appendMethod · 0.45
writeMethod · 0.45
meanMethod · 0.45
flushMethod · 0.45

Tested by 6

_testCondMethod · 0.36
__init__Method · 0.36
test_function_basicsMethod · 0.36