-
Notifications
You must be signed in to change notification settings - Fork 4.3k
[Term Entry] PyTorch Sigmoid Example #8105
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
base: main
Are you sure you want to change the base?
Conversation
Updated the title to '.sigmoid()' and clarified the description of the sigmoid function.
mamtawardhani
left a comment
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 @aedpluto, I've requested some changes in this entry, could you please check and tag me once those are done? Thank you! 😄
| @@ -0,0 +1,45 @@ | |||
| --- | |||
| Title: '.sigmoid()' | |||
| Description: 'The sigmoid function is an S-shaped curve typically used in binary classification problems' | |||
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 always start with a verb, and this description is slightly incorrect. A correct example description could be: "Applies the sigmoid activation to each element of a tensor, mapping values to a range between 0 and 1."
| A **`.sigmoid()`** function is an S-shaped curve which maps any real-valued input to a bounded output, typically between 0 and 1. Sigmoid functions are regularly used as activation functions in non-linear classification problems, for example in neural networks, where the probability of a binary outcome is required. | ||
|
|
||
| Although there are a range of sigmoid functions, in the field of AI the sigmoid function is usually synonymous with the logistic function, which is bound between 0 and 1. |
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 this be made better? It is modtly correct, but it needs a small adjustment for precision and tone, especially since this is about PyTorch’s .sigmoid() and not sigmoid functions in general. Example:
"The .sigmoid() function applies the sigmoid (logistic) function to each element of a tensor, producing an S-shaped curve that maps any real-valued input to a value between 0 and 1.
In machine learning, sigmoid is commonly used as an activation function in binary classification tasks, where outputs represent probabilities."
| The formula for the sigmoid function is given by: | ||
| $$σ(x) = 1 / (1 + e^(-x))$$ | ||
|
|
||
| ## Examples |
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.
| ## Examples | |
| ## Example |
| x = torch.linspace(-10, 10, steps=400) | ||
| y = torch.sigmoid(x) | ||
|
|
||
| plt.plot(x.numpy(), y.numpy() |
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 parenthesis are not closing and that will give an error, please fix that
| plt.xlabel("x") | ||
| plt.ylabel("σ(x)") | ||
| plt.show() | ||
| ``` |
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.
Please attach the image of the output here, and I also suggest to add one more example that shows practical uses, example Applying .sigmoid() to a Tensor
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.
Many thanks - I've now updated the file with the changes. I just wanted to double check whether I tag you in a comment like this when I reupload the file or do I tag you somewhere else? (I'm very new to collaborating on GitHub so wanted to double check) |
|
@mamtawardhani I've tried to rebase onto the latest branch and pushed the updated commit. Please let me know if anything else is needed. |

Description
Issue Solved
Type of Change
Checklist
mainbranch.Issues Solvedsection.