Skip to content

Conversation

@ylevental
Copy link
Contributor

Description

Added term entry for PyTorch's .sgn() function at content/pytorch/concepts/tensor-operations/terms/sgn/sgn.md.

The function computes element-wise sign:

  • Real tensors: returns -1, 0, or 1
  • Complex tensors: returns unit vector (x/|x|)

Includes three examples demonstrating 1D real tensors, 2D tensors, and complex number behavior.

Metadata follows patterns from similar operations (.neg(), .positive()): Computer Science and Data Science subjects, Deep Learning/Methods/PyTorch/Tensor tags.

Issue Solved

Closes #8082

Type of Change

  • Adding a new entry

Checklist

  • All writings are my own.
  • My entry follows the Codecademy Docs style guide.
  • My changes generate no new warnings.
  • I have performed a self-review of my own writing and code.
  • I have checked my entry and corrected any misspellings.
  • I have made corresponding changes to the documentation if needed.
  • I have confirmed my changes are not being pushed from my forked main branch.
  • I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • I have linked any issues that are relevant to this PR in the Issues Solved section.

@mamtawardhani mamtawardhani self-assigned this Dec 16, 2025
Clarify the description of the second example for .sgn() usage.
Copy link
Collaborator

@mamtawardhani mamtawardhani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for a second review! 🚀

Copy link
Collaborator

@dakshdeepHERE dakshdeepHERE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@dakshdeepHERE dakshdeepHERE merged commit 9db7986 into Codecademy:main Jan 5, 2026
7 checks passed
@github-actions
Copy link

github-actions bot commented Jan 5, 2026

👋 @ylevental
You have contributed to Codecademy Docs, and we would like to know more about you and your experience.
Please take a minute to fill out this four question survey to help us better understand Docs contributions and how we can improve the experience for you and our learners.
Thank you for your help!

🎉 Your contribution(s) can be seen here:

https://www.codecademy.com/resources/docs/pytorch/tensor-operations/sgn

Please note it may take a little while for changes to become visible.
If you're appearing as anonymous and want to be credited, visit the linked accounts page and ensure that your GitHub account is linked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Term Entry] PyTorch Tensor Operations: .sgn()

3 participants