本文整理汇总了Python中ProgressBar.ProgressBar.increment_amount方法的典型用法代码示例。如果您正苦于以下问题:Python ProgressBar.increment_amount方法的具体用法?Python ProgressBar.increment_amount怎么用?Python ProgressBar.increment_amount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgressBar.ProgressBar
的用法示例。
在下文中一共展示了ProgressBar.increment_amount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment_amount [as 别名]
def main( iterations, ensembles, episodes, agent_type, agent_args, env_type, env_args, file_prefix ):
"""RL Testbed.
@arg iterations: Number of environments to average over
@arg ensembles: Number of bots to average over
@arg episodes: Number of episodes to run for
@arg agent_type: String name of agent
@arg agent_args: Arguments to the agent constructor
@arg env_type: String name of environment
@arg env_args: Arguments to the environment constructor
"""
# Load agent and environment
progress = ProgressBar( 0, ensembles*iterations, mode='fixed' )
# Needed to prevent glitches
oldprog = str(progress)
# Counters
ret = np.zeros( episodes, dtype=float )
min_, max_ = np.inf * np.ones( episodes, dtype=float) , -np.inf * np.ones( episodes, dtype=float)
var = np.zeros( episodes, dtype=float )
env = env_type.create( *env_args )
for i in xrange( 1, iterations+1 ):
env = env.domain.reset_rewards( env, *env_args )
ret_ = np.zeros( episodes, dtype=float )
# Initialise environment and agent
for j in xrange( 1, ensembles+1 ):
print "iter, ens", i, j
agent = agent_type( env.Q, *agent_args )
ret__ = Runner.run( env, agent, episodes )
ret__ = np.cumsum( ret__ ) #Varun
# Add to ret_
ret_ += (ret__ - ret_) / j
# print progress
progress.increment_amount()
if oldprog != str(progress):
print progress, "\r",
sys.stdout.flush()
oldprog=str(progress)
ret += (ret_ - ret) / i
min_ = np.min( np.vstack( ( min_, ret_ ) ), axis=0 )
max_ = np.max( np.vstack( ( max_, ret_ ) ), axis=0 )
var_ = np.power( ret_, 2 )
var += (var_ - var) / i
print "\n"
var = np.sqrt( var - np.power( ret, 2 ) )
f = open("%s-return.dat"%( file_prefix ), "w")
# Print ret
for i in xrange( len( ret ) ):
f.write( "%d %f %f %f %f\n"%( i+1, ret[ i ], min_[i], max_[i], var[ i ] ) )
f.close()
示例2: progressIter
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment_amount [as 别名]
def progressIter( fn, lst ):
progress = ProgressBar( 0, len(lst), mode='fixed' )
oldprog = str(progress)
for n in lst:
v = fn( n )
if v:
progress.update_amount(v)
else:
progress.increment_amount()
if oldprog != str(progress):
print progress, "\r",
sys.stdout.flush()
oldprog=str(progress)
print '\n'
示例3: progressMap
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment_amount [as 别名]
def progressMap( fn, lst ):
progress = ProgressBar( 0, len(lst), mode='fixed' )
oldprog = str(progress)
out = []
for n in lst:
v = fn( n )
out.append( v )
progress.increment_amount()
if oldprog != str(progress):
print progress, "\r",
sys.stdout.flush()
oldprog=str(progress)
print '\n'
return out