2015-08-16 132 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