2015-08-16 121 views
-1
present_coefiecients = random.sample(xrange(1,50),5) 
present_value = random.sample(xrange(1,100),5) 
present_weights = ap.array('0;0;0;0;0') 
print present_coefiecients 
print present_value 
print present_weights 
c = [a*b for a,b in zip(present_coefiecients,present_value)] 
layer_1 = ap.log2(c) 
print layer_1 

我怎么能运行这些指令集的50倍,所以我可以得到的layer_1每次打印数组多次

+0

把这段代码放在一个函数中并在循环中调用该函数? – thefourtheye

回答

0

好不同的值,因为这只是用一种for循环:

for i in range(50): 
    present_coefiecients = random.sample(xrange(1,50),5) 
    present_value = random.sample(xrange(1,100),5) 
    present_weights = ap.array('0;0;0;0;0') 
    print present_coefiecients 
    print present_value 
    print present_weights 
    c = [a*b for a,b in zip(present_coefiecients,present_value)] 
    layer_1 = ap.log2(c) 
    print layer_1