-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Term Entry] PyTorch Tensor Operations: .row_stack() (#5887)
* [Term Entry] PyTorch Tensor Operations: .row_stack() * Update row-stack.md minor fix ---------
- Loading branch information
1 parent
6f4d8c9
commit 37bd936
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
content/pytorch/concepts/tensor-operations/terms/row-stack/row-stack.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
Title: '.row_stack()' | ||
Description: 'Stacks or arranges a sequence of tensors vertically (row-wise).' | ||
Subjects: | ||
- 'AI' | ||
- 'Data Science' | ||
Tags: | ||
- 'AI' | ||
- 'Data Types' | ||
- 'Deep Learning' | ||
- 'Functions' | ||
CatalogContent: | ||
- 'intro-to-py-torch-and-neural-networks' | ||
- 'paths/data-science' | ||
--- | ||
|
||
In PyTorch, the **`.row_stack()`** function stacks or arranges a sequence of [tensors](https://www.codecademy.com/resources/docs/pytorch/tensors) vertically (row-wise). It is an alias or alternative for the **`.vstack()`** function. | ||
|
||
## Syntax | ||
|
||
```pseudo | ||
torch.row_stack(tensors, *, out=None) | ||
``` | ||
|
||
- `tensors`: The sequence of tensors to be stacked vertically. | ||
- `out` (Optional): A tensor to store the output. It must have the correct shape to accommodate the result. | ||
|
||
## Example | ||
|
||
The following example demonstrates the usage of the `.row_stack()` function: | ||
|
||
```py | ||
import torch | ||
|
||
# Create two tensors | ||
ten1 = torch.tensor([12, 23, 34]) | ||
ten2 = torch.tensor([45, 56, 67]) | ||
|
||
# Stack the tensors vertically | ||
res = torch.row_stack((ten1, ten2)) | ||
|
||
# Print the resultant tensor | ||
print(res) | ||
``` | ||
|
||
The above code produces the following output: | ||
|
||
```shell | ||
tensor([[12, 23, 34], | ||
[45, 56, 67]]) | ||
``` |