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


Python Timer.over方法代码示例

本文整理汇总了Python中timer.Timer.over方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.over方法的具体用法?Python Timer.over怎么用?Python Timer.over使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在timer.Timer的用法示例。


在下文中一共展示了Timer.over方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save_dataset

# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import over [as 别名]
def save_dataset(X,y,file_path):
    print "saving extended dataset..."
    print "saving %d images..." % X.shape[0]

    f = open(file_path,"w")
    z = zip(X,y)
    np.random.shuffle(z)
    t = Timer(X.shape[0])
    t.start()
    for X, y in z:
        f.write("%d,\"%s\"\n" % (np.int(np.argmax(y)), " ".join([str(i) for i in X.flatten().astype(int)])))
        t.print_update(1)
    f.close()
    print "it took",seconds_to_string(t.over())
开发者ID:Kerkil,项目名称:ift6266kaggle,代码行数:16,代码来源:__init__.py

示例2: apply_transformations

# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import over [as 别名]
def apply_transformations(X,y,transformations):
    
    nb = X.shape[0]
    for name, settings in transformations.items():
        nb = nb + nb * settings.get('ratio',2)

    print "A dataset of approximately %d images will we produced.." % nb
       
    if nb*257*2**20/(0.+2**30*33423)*4 > 4.0:
        a = ""
        while a not in ["y","n"]:
            a = raw_input("This may use more than %dG of RAM. Do you want to continue? (y/n) " % (nb*257*2**20/(0.+2**30*33423)*4))
            if a=='n':
                sys.exit(0)

    t = Timer(nb)
    t.start()

    tX = X[:]
    ty = y[:]
    noise_transformations = []
    for noise_t in ['noise','sharpen','denoise']:
        if noise_t in transformations:
            settings = transformations.pop(noise_t)
            nX, ny = generate(transformations_dict[noise_t],settings,X,y,t=t)
            tX = np.vstack((tX,nX))
            ty = np.vstack((ty,ny))

    X = tX
    y = ty
    for name, settings in transformations.items():
        nX, ny = generate(transformations_dict[name],settings,X,y,t=t)
        X = np.vstack((X,nX))
        y = np.vstack((y,ny))

    print "it took",seconds_to_string(t.over())

    return X, y
开发者ID:Kerkil,项目名称:ift6266kaggle,代码行数:40,代码来源:__init__.py


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