本文整理汇总了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())
示例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