The == numpy

== numpy in Comparative representative of two of the same size on the array element corresponding to the position are equal, are equal Returns True (1), not equal Falss (0) is returned, the end result is the same size array and the two Boolean array, examples are as follows:

import numpy as np

x1 = np.random.randint(0,5,(3,4))
x2 = np.random.randint(0,5,(3,4))
print(x1)
print(x2)
print(x1==x2)

输出结果为:
[[0 1 1 4]
 [2 0 3 1]
 [2 2 0 3]]
[[3 1 2 2]
 [1 2 1 1]
 [0 1 3 1]]
[[False  True False False]
 [False False False  True]
 [False False False False]]
np.random.randint (0,5, (3,4)) representative of the size of the resulting [3,4], the value range of 0-5 (excluding 5) of the array
Published 36 original articles · won praise 11 · views 6525

Guess you like

Origin blog.csdn.net/t20134297/article/details/105007494