pymc.math.neq#
- pymc.math.neq = Elemwise(scalar_op=NEQ,inplace_pattern=<frozendict {}>)[source]#
a != b
Computes element-wise inequality comparison between two tensors.
- Parameters:
- a
TensorLike
First input tensor
- b
TensorLike
Second input tensor
- a
- Returns:
TensorVariable
Output tensor of type bool, with 1 (True) where a != b, and 0 (False) elsewhere.
Notes
Due to Python rules, it is not possible to overload the inequality symbol != for hashable objects and have it return something other than a boolean, so neq must always be used to compute the Elemwise inequality of TensorVariables (which are hashable).
Examples
>>> import pytensor >>> import pytensor.tensor as pt >>> x = pt.vector("x") >>> y = pt.vector("y") >>> f = pytensor.function([x, y], pt.neq(x, y)) >>> f([1, 2, 3], [1, 4, 3]) array([False, True, False])