import numpy as np
# : 表示所有的行。
# 标记
reward_indicator = np.zeros([10, 5])
process_delay = np.zeros([10, 5])
process_delay[0,0] = 1
process_delay[0,1] = 1
process_delay[0,2] = 1
process_delay[1,2] = 1
process_delay[2,2] = 1
for iot_index in range(5):
update_index = np.where(
(1 - reward_indicator[:, iot_index]) * process_delay[:, iot_index] > 0
)[0]
print("--", np.where(
(1 - reward_indicator[:, iot_index]) * process_delay[:, iot_index] > 0
))
# (array([0, 1, 2], dtype=int64),)
print("update_index:", update_index)
a = np.array([2,4,6,8,10])
b = np.where(a > 3)
~~** # print('b:', b)b: (array([1, 2, 3, 4], dtype=int64),) **~~
# print('b[0][0]:', b[0][0])b[0]: 1
# print('b[0]:', b[0])b[0]: [1, 2, 3, 4]
# print(a[0])2
numpy np.where
最新推荐文章于 2024-07-30 11:50:19 发布