ne¶
Documentation¶
-
treetensor.torch.
ne
(input, other, *args, **kwargs)[source]¶ In
treetensor
, you can get the non-equality of the two tree tensors withne()
.Examples:
>>> import torch >>> import treetensor.torch as ttorch >>> ttorch.ne( ... torch.tensor([[1, 2], [3, 4]]), ... torch.tensor([[1, 1], [4, 4]]), ... ) tensor([[False, True], [ True, False]]) >>> ttorch.ne( ... ttorch.tensor({ ... 'a': [[1, 2], [3, 4]], ... 'b': [1.0, 1.5, 2.0], ... }), ... ttorch.tensor({ ... 'a': [[1, 1], [4, 4]], ... 'b': [1.3, 1.2, 2.0], ... }), ... ) <Tensor 0x7ff363bb6cf8> ├── a --> tensor([[False, True], │ [ True, False]]) └── b --> tensor([ True, True, False])
Torch Version Related
This documentation is based on torch.ne in torch v2.4.1+cu121. Its arguments’ arrangements depend on the version of pytorch you installed.
If some arguments listed here are not working properly, please check your pytorch’s version with the following command and find its documentation.
1 | python -c 'import torch;print(torch.__version__)' |
The arguments and keyword arguments supported in torch v2.4.1+cu121 is listed below.
Description From Torch v2.4.1+cu121¶
-
torch.
ne
(input, other, *, out=None) → Tensor¶ Computes \(\text{input} \neq \text{other}\) element-wise.
The second argument can be a number or a tensor whose shape is broadcastable with the first argument.
- Args:
input (Tensor): the tensor to compare other (Tensor or float): the tensor or value to compare
- Keyword args:
out (Tensor, optional): the output tensor.
- Returns:
A boolean tensor that is True where
input
is not equal toother
and False elsewhere
Example:
>>> torch.ne(torch.tensor([[1, 2], [3, 4]]), torch.tensor([[1, 1], [4, 4]])) tensor([[False, True], [True, False]])