Skip to content

Commit ba62d15

Browse files
authored
Update logical-or.md
1 parent 6cb5e32 commit ba62d15

File tree

1 file changed

+9
-9
lines changed
  • content/pytorch/concepts/tensor-operations/terms/logical-or

1 file changed

+9
-9
lines changed

content/pytorch/concepts/tensor-operations/terms/logical-or/logical-or.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ CatalogContent:
1313
- 'paths/data-science'
1414
---
1515

16-
The **`.logical_or()`** function performs an element-wise logical OR operation between two [tensors](https://www.codecademy.com/resources/docs/pytorch/tensors). The result contains Boolean values where each element is `True` if either corresponding element in the inputs evaluates to non-zero. Inputs are interpreted as Boolean: zero values are considered `False`, and non-zero values are considered `True`.
16+
The **`.logical_or()`** function performs an element-wise logical OR operation between two [tensors](https://www.codecademy.com/resources/docs/pytorch/tensors). Each input value is converted to a Boolean value (zero → `False`, non-zero → `True`) before the operation. The output is a Boolean tensor where each element is `True` if at least one of the corresponding input elements is `True`.
1717

1818
## Syntax
1919

@@ -29,7 +29,7 @@ torch.logical_or(input, other, out)
2929

3030
**Return value:**
3131

32-
Returns a Boolean tensor where each position is `True` if either corresponding element in the inputs evaluates as `True`.
32+
Returns a Boolean tensor where each element is `True` if at least one of the corresponding input elements is `True`.
3333

3434
## Example 1
3535

@@ -52,16 +52,16 @@ The output of this code is:
5252

5353
```shell
5454
Tensor A:
55-
tensor([[0, 1],
55+
tensor([[0, 1],
5656
[2, 0]])
5757

5858
Tensor B:
59-
tensor([[3, 0],
59+
tensor([[3, 0],
6060
[0, 5]])
6161

6262
A OR B:
63-
tensor([[ True, True],
64-
[ True, True]])
63+
tensor([[True, True],
64+
[True, True]])
6565
```
6666

6767
## Example 2
@@ -82,19 +82,19 @@ print(result)
8282
The output of this code is:
8383

8484
```shell
85-
tensor([ True, True, True, True])
85+
tensor([True, True, True, True])
8686
```
8787

8888
## Frequently Asked Questions
8989

9090
### 1. What are the tensor operations in PyTorch?
9191

92-
Tensor operations include arithmetic, logical operations, reductions, reshaping, indexing, broadcasting, and matrix operations. These operations run efficiently on CPU or GPU and form the core building blocks of neural network workflows.
92+
Tensor operations in PyTorch include arithmetic, logical operations, reductions, reshaping, indexing, broadcasting, and matrix operations. These operations run efficiently on CPU or GPU and form the core building blocks of neural network workflows.
9393

9494
### 2. Why use tensor instead of NumPy?
9595

9696
Tensors support automatic differentiation and execute seamlessly on GPUs, which makes them suited for deep learning workloads. They also integrate tightly with PyTorch's computation graph, while NumPy arrays operate only on the CPU and lack gradient support.
9797

98-
### 3. What does CPU() do in PyTorch?
98+
### 3. What does cpu() do in PyTorch?
9999

100100
The `.cpu()` method moves a tensor or model from a GPU device to the system’s CPU. This is useful for running operations on hardware without CUDA support or preparing data for libraries that operate only on CPU-based arrays.

0 commit comments

Comments
 (0)