本文整理汇总了Python中progressbar.Counter方法的典型用法代码示例。如果您正苦于以下问题:Python progressbar.Counter方法的具体用法?Python progressbar.Counter怎么用?Python progressbar.Counter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类progressbar
的用法示例。
在下文中一共展示了progressbar.Counter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_bar
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Counter [as 别名]
def create_bar(self):
"""Create a new progress bar.
Calls `self.get_iter_per_epoch()`, selects an appropriate
set of widgets and creates a ProgressBar.
"""
iter_per_epoch = self.get_iter_per_epoch()
epochs_done = self.main_loop.log.status['epochs_done']
if iter_per_epoch is None:
widgets = ["Epoch {}, step ".format(epochs_done),
progressbar.Counter(), ' ',
progressbar.BouncingBar(), ' ',
progressbar.Timer()]
iter_per_epoch = progressbar.UnknownLength
else:
widgets = ["Epoch {}, step ".format(epochs_done),
progressbar.Counter(),
' (', progressbar.Percentage(), ') ',
progressbar.Bar(), ' ',
progressbar.Timer(), ' ', progressbar.ETA()]
return progressbar.ProgressBar(widgets=widgets,
max_value=iter_per_epoch)
示例2: _make_progressbar
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Counter [as 别名]
def _make_progressbar(self, N):
""" Returns a progressbar to use during optimization"""
if self.max_ind_shift is not None:
bar = progressbar.ProgressBar(widgets=[
' ', progressbar.DynamicMessage('ObjectiveFn'),
' ', progressbar.DynamicMessage('ObjectiveFn_Normalized'),
' Iteration: ',
' ', progressbar.Counter(), '/%d' % N,
' ', progressbar.AdaptiveETA(),
], max_value=N)
else:
bar = progressbar.ProgressBar(widgets=[
' ', progressbar.DynamicMessage('ObjectiveFn'),
' Iteration: ',
' ', progressbar.Counter(), '/%d' % N,
' ', progressbar.AdaptiveETA(),
], max_value=N)
return bar
示例3: run
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Counter [as 别名]
def run(self):
try:
from progressbar import ProgressBar, Bar, Counter, Timer, ETA, Percentage, RotatingMarker
widgets = [Percentage(), Bar(left='[', right=']'), ' Processed: ', Counter(), '/', "%s" % self.task_count, ' total files (', Timer(), ') ', ETA()]
pb = ProgressBar(widgets=widgets, maxval=self.task_count).start()
while self.task_queue.qsize():
pb.update(self.task_count - self.task_queue.qsize())
time.sleep(0.5)
pb.finish()
except KeyboardInterrupt:
warning("progressbar interrupted by user\n")
return 1
except ImportError:
warning("progressbar module not available")
except:
warning("unknown error from progress bar")
return 0
示例4: progress_bar
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Counter [as 别名]
def progress_bar(event):
if event == 'Checking' or event == 'Calculating':
widgets = [progressbar.AnimatedMarker(), ' ', event + ' (Queue: ', progressbar.Counter(), ') ', progressbar.Timer()]
bar = progressbar.ProgressBar(widgets=widgets, max_value=progressbar.UnknownLength)
else:
widgets = [event + ' ', progressbar.Bar(), progressbar.Percentage(),
' (', progressbar.Timer(), ', ', progressbar.ETA(), ')']
bar = progressbar.ProgressBar(widgets=widgets, max_value=100)
return bar
示例5: update_embedding
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Counter [as 别名]
def update_embedding(self, session, batch_size):
embedding_size = self._dataset.embedding_size
J = self._encoder.latent_space_size
embedding_z = np.empty( (embedding_size, J) )
obj_bbs = np.empty( (embedding_size, 4) )
widgets = ['Creating embedding ..: ', progressbar.Percentage(),
' ', progressbar.Bar(),
' ', progressbar.Counter(), ' / %s' % embedding_size,
' ', progressbar.ETA(), ' ']
bar = progressbar.ProgressBar(maxval=embedding_size,widgets=widgets)
bar.start()
for a, e in u.batch_iteration_indices(embedding_size, batch_size):
batch, obj_bbs_batch = self._dataset.render_embedding_image_batch(a, e)
embedding_z[a:e] = session.run(self._encoder.z, feed_dict={self._encoder.x: batch})
if self.embed_bb:
obj_bbs[a:e] = obj_bbs_batch
bar.update(e)
bar.finish()
# embedding_z = embedding_z.T
normalized_embedding = embedding_z / np.linalg.norm( embedding_z, axis=1, keepdims=True )
session.run(self.embedding_assign_op, {self.embedding: normalized_embedding})
if self.embed_bb:
session.run(self.embed_obj_bbs_assign_op, {self.embed_obj_bbs: obj_bbs})
示例6: __init__
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Counter [as 别名]
def __init__(self,interface_type,count=None,description=None):
self.interface_type = interface_type
self.current_value = 0
if self.interface_type == Config.UI_CLI:
widgets = []
if description is not None:
widgets.append('{}: '.format(description))
if count is not None:
widgets.append(Percentage())
widgets.append(' ')
widgets.append(Bar())
else:
widgets.append(Counter())
widgets.append(' ')
widgets.append(AnimatedMarker(markers='.oO@* '))
if count is not None:
self.progressBar = ProgressBar(widgets=widgets, max_value=count)
else:
self.progressBar = ProgressBar(max_value=progressbar.UnknownLength,widgets=widgets)
else:
PROGRESS_LOGGER.error('interface type not handled: {}'.format(self.interface_type))
raise Exception('interface type not handled: {}'.format(self.interface_type))
示例7: bruteforce_possibilities
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Counter [as 别名]
def bruteforce_possibilities(possibilities):
# let's try those values!
print('[*] example guess: %r' % b''.join(possibilities[0]))
print('[*] brute-forcing %d possibilities' % len(possibilities))
for guess in progressbar.ProgressBar(widgets=[progressbar.Counter(), ' ', progressbar.Percentage(), ' ', progressbar.Bar(), ' ', progressbar.ETA()])(possibilities):
guess_str = b''.join(guess)
stdout,_ = subprocess.Popen(["./whitehat_crypto400", guess_str.decode("ascii")], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()
if b'FLAG IS' in stdout:
return next(filter(lambda s: guess_str in s, stdout.split()))
示例8: perform_epoch
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Counter [as 别名]
def perform_epoch(self):
n_datapoints = self.dataset.n_datapoints
batch_size = self.batch_size
n_batches = n_datapoints // batch_size
epoch = self.step // n_batches
LL_epoch = 0
self.update_shvars()
self.shuffle_train_data()
# Update learning rated
self.shvar['lr_p'].set_value((self.calc_learning_rates(self.learning_rate_p / self.lr_decay**epoch)).astype(floatX))
self.shvar['lr_q'].set_value((self.calc_learning_rates(self.learning_rate_q / self.lr_decay**epoch)).astype(floatX))
self.shvar['lr_s'].set_value((self.calc_learning_rates(self.learning_rate_s / self.lr_decay**epoch)).astype(floatX))
widgets = ["Epoch %d, step "%(epoch+1), pbar.Counter(), ' (', pbar.Percentage(), ') ', pbar.Bar(), ' ', pbar.Timer(), ' ', pbar.ETA()]
bar = pbar.ProgressBar(widgets=widgets, maxval=n_batches).start()
t0 = time()
while True:
LL = self.perform_step(update=False)
LL_epoch += LL
batch_idx = self.step % n_batches
bar.update(batch_idx)
if self.step % n_batches == 0:
break
t = time()-t0
bar.finish()
LL_epoch /= n_batches
self.logger.info("Completed epoch %d in %.1fs (%.1fms/step). Calling epoch_monitors..." % (epoch+1, t, t/n_batches*1000))
for m in self.epoch_monitors:
m.on_iter(self.model)
self.dlog.append_all({
'timing.epoch': t,
'timing.step': t/n_batches
})
return LL_epoch