多次打印阵列

2024-03-28 08:48:38 发布

您现在位置:Python中文网/ 问答频道 /正文

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次,以便每次都能得到不同的层1的值


Tags: sampleinlayerforvaluerandomziplog2
1条回答
网友
1楼 · 发布于 2024-03-28 08:48:38

好吧,为此只需使用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

相关问题 更多 >