-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Term Entry] PyTorch Tensor Operations .hstack() #5528
base: main
Are you sure you want to change the base?
[Term Entry] PyTorch Tensor Operations .hstack() #5528
Conversation
fixed meta data table
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @clonymontana thank you for contributing to Codecademy Docs 😄
I've suggested some changes, could you please review and modify those at your earliest convenience? Thank you! 🚀
--- | ||
Title: '.hstack()' | ||
Description: 'The `.hastack(tensors)` is a function used to concetante two or more tensors along horizontal axis.' | ||
Subjects: | ||
- 'AI' | ||
- 'Data Science' | ||
Tags: | ||
- 'AI' | ||
- 'Data Types' | ||
- 'Deep Learning' | ||
- 'Functions' | ||
CatalogContent: | ||
- 'intro-to-py-torch-and-neural-networks' | ||
- 'paths/data-science' | ||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--- | |
Title: '.hstack()' | |
Description: 'The `.hastack(tensors)` is a function used to concetante two or more tensors along horizontal axis.' | |
Subjects: | |
- 'AI' | |
- 'Data Science' | |
Tags: | |
- 'AI' | |
- 'Data Types' | |
- 'Deep Learning' | |
- 'Functions' | |
CatalogContent: | |
- 'intro-to-py-torch-and-neural-networks' | |
- 'paths/data-science' | |
--- | |
--- | |
Title: '.hstack()' | |
Description: 'Concatenates two or more tensors along the horizontal axis (column-wise)' | |
Subjects: | |
- 'AI' | |
- 'Data Science' | |
Tags: | |
- 'AI' | |
- 'Data Types' | |
- 'Deep Learning' | |
- 'Functions' | |
CatalogContent: | |
- 'intro-to-py-torch-and-neural-networks' | |
- 'paths/data-science' | |
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description should start with a verb
- 'paths/data-science' | ||
--- | ||
|
||
In PyTorch, **`.hastack()`** (short for horizontal stack)is a function used to concatenate two or more tensors along the horizontal axis (axis1). This operation is useful for combining data with the same number of rows but differing in the number of columns. It acts similarly to numpy's 'np.hastack()' and is particulary handy when you're working with data that needs to be concatenated side by side before being fed into a model for training or inference. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In PyTorch, **`.hastack()`** (short for horizontal stack)is a function used to concatenate two or more tensors along the horizontal axis (axis1). This operation is useful for combining data with the same number of rows but differing in the number of columns. It acts similarly to numpy's 'np.hastack()' and is particulary handy when you're working with data that needs to be concatenated side by side before being fed into a model for training or inference. | |
In PyTorch, **`.hstack()`** (short for horizontal stack) is a function used to concatenate two or more tensors along the horizontal axis (`axis=1`). This operation is helpful in combining data with the same number of rows but differing in the number of columns. It acts similarly to NumPy's `np.hstack()` and is particularly handy for data that needs to be concatenated side by side before being fed into a model for training or inference. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed spelling mistakes and reframed the sentence a bit
|
||
The basic syntax of `.hstack()` in PyTorch is as falows: | ||
|
||
```python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
```python | |
```pseudo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax is to be wrapped in the pseudo
block
|
||
Where: | ||
|
||
- `tensors` is a sequence of tesors with the same numbers of rows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `tensors` is a sequence of tesors with the same numbers of rows. | |
- `tensors`: A sequence of tensors with the same number of rows. All tensors must have the same number of dimensions and the same size in all dimensions except for the dimension corresponding to the horizontal stacking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be elaborated
Where: | ||
|
||
- `tensors` is a sequence of tesors with the same numbers of rows. | ||
- The function returns a new tensor containing the horizontal concatenation of the imput tensors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The function returns a new tensor containing the horizontal concatenation of the imput tensors. | |
The function returns a new tensor containing the horizontal concatenation of the input tensors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No bullet point needed as it is not a parameter
b = torch.tensor([[5, 6],[7, 8]]) | ||
|
||
# Horizontal stack | ||
c = toarch.hstack((a, b)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c = toarch.hstack((a, b)) | |
c = torch.hstack((a, b)) |
|
||
# Exemple | ||
|
||
Here's simple example demonstrating how '.hstack()' can be used to concatenate tensors: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's simple example demonstrating how '.hstack()' can be used to concatenate tensors: | |
Here's an example demonstrating how `.hstack()` can be used to concatenate tensors: |
|
||
# Codebyte Exemple | ||
|
||
```python | ||
import torch | ||
|
||
# Create 1D tensors | ||
a = torch.tensor([1, 2]) | ||
b = torch.tensor([3, 4]) | ||
|
||
# Horizontal stack | ||
c = torch.tensor((a, b)) | ||
|
||
print(c) | ||
``` | ||
In this Codebyte example, two 1-dimensional tensors are horizontally concatenated, showcasing how `.hstack()`seamlessly combines tensors not just in 2D but also in 1D tensors, further emphasizing the function's utility in handling tensors of varios dimensions as long as thay share the same number of rows (or are all 1-dimensional). | ||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed since the Codecademy Compiler does not have PyTorch dependencies yet.
Hello @mamtawardhani Thank you for the opportunity to contribute 😄 |
5d50bf1
to
0a0bae9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing to Codecademy Docs @clonymontana 😄
The entry looks good for a second round of review! 🚀
e3b1da1
to
8fb51fd
Compare
Description
-Added the .hstack() function term under PyTorch
-Closes Issues #5468
Issue Solved
Type of Change
Checklist
main
branch.Issues Solved
section.