当前位置: 首页>>代码示例>>Python>>正文


Python ProgressBar.increment_amount方法代码示例

本文整理汇总了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()
开发者ID:sriramvasudevan,项目名称:rl-project,代码行数:59,代码来源:main.py

示例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'
开发者ID:arunchaganty,项目名称:Small-World-RL,代码行数:19,代码来源:util.py

示例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
开发者ID:arunchaganty,项目名称:Small-World-RL,代码行数:21,代码来源:util.py


注:本文中的ProgressBar.ProgressBar.increment_amount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。