le¶
Documentation¶
-
treetensor.torch.
le
(input, other, *args, **kwargs)[source]¶ In
treetensor
, you can get less-than-or-equal situation of the two tree tensors withle()
.Examples:
>>> import torch >>> import treetensor.torch as ttorch >>> ttorch.le( ... torch.tensor([[1, 2], [3, 4]]), ... torch.tensor([[1, 1], [4, 4]]), ... ) tensor([[ True, False], [ True, True]]) >>> ttorch.le( ... 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 0x7ff363bc6198> ├── a --> tensor([[ True, False], │ [ True, True]]) └── b --> tensor([ True, False, True])
Torch Version Related
This documentation is based on torch.le in torch v1.10.0+cu102. 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 v1.10.0+cu102 is listed below.
Description From Torch v1.10.0+cu102¶
-
torch.
le
(input, other, *, out=None) → Tensor¶ Computes \(\text{input} \leq \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 Scalar): the tensor or value to compare
- Keyword args:
out (Tensor, optional): the output tensor.
- Returns:
A boolean tensor that is True where
input
is less than or equal toother
and False elsewhere
Example:
>>> torch.le(torch.tensor([[1, 2], [3, 4]]), torch.tensor([[1, 1], [4, 4]])) tensor([[True, False], [True, True]])