[英]how to use np.argmax calculate the max difference between elements in one vector?
像這樣獲得一個向量中元素之間的最大差異,但這個例子總是 output 0
s = [1,2,3,5]
print(np.argmax(s[i+1]-s[i] for i in range(len(s)-1)))
不要通過生成器。 傳遞一個列表,即在argmax
中添加方括號:
np.argmax([s[i+1]-s[i] for i in range(len(s)-1)])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.