From 1ba32fc17c7513e6f7081147851541ae111ed498 Mon Sep 17 00:00:00 2001 From: Amy Page Date: Tue, 16 Dec 2025 21:42:05 +0000 Subject: [PATCH 1/3] Add new description of sigmoid function in sigmoid.md --- .../terms/sigmoid/sigmoid.md | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 content/pytorch/concepts/tensor-operations/terms/sigmoid/sigmoid.md diff --git a/content/pytorch/concepts/tensor-operations/terms/sigmoid/sigmoid.md b/content/pytorch/concepts/tensor-operations/terms/sigmoid/sigmoid.md new file mode 100644 index 00000000000..d296a05e761 --- /dev/null +++ b/content/pytorch/concepts/tensor-operations/terms/sigmoid/sigmoid.md @@ -0,0 +1,45 @@ +--- +Title: 'sigmoid' +Description: 'The sigmoid function is an S-shaped curve typically used in binary classification problems' +Subjects: + - 'AI' + - 'Machine Learning' +Tags: + - 'AI' + - 'Classification' + - 'Logistic Regression' + - 'Machine Learning' + - 'Math' + - 'Models' + - 'Neural Networks' + - 'Python' + - 'PyTorch' +CatalogContent: + - 'py-torch-for-classification' +  - 'intro-to-py-torch-and-neural-networks' +--- + +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. + +The formula for the sigmoid function is given by: +$$σ(x) = 1 / (1 + e^(-x))$$ + +## Examples + +The following example plots the sigmoid function: + +```py +import matplotlib.pyplot as plt +import torch + +x = torch.linspace(-10, 10, steps=400) +y = torch.sigmoid(x) + +plt.plot(x.numpy(), y.numpy() +plt.title("Sigmoid function") +plt.xlabel("x") +plt.ylabel("σ(x)") +plt.show() +``` From 30dcd5a1db94cd8127a0bc83119528e2bec67edb Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Wed, 17 Dec 2025 16:14:31 +0530 Subject: [PATCH 2/3] Revise title and description for sigmoid function Updated the title to '.sigmoid()' and clarified the description of the sigmoid function. --- .../concepts/tensor-operations/terms/sigmoid/sigmoid.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/pytorch/concepts/tensor-operations/terms/sigmoid/sigmoid.md b/content/pytorch/concepts/tensor-operations/terms/sigmoid/sigmoid.md index d296a05e761..8a0e107c76e 100644 --- a/content/pytorch/concepts/tensor-operations/terms/sigmoid/sigmoid.md +++ b/content/pytorch/concepts/tensor-operations/terms/sigmoid/sigmoid.md @@ -1,5 +1,5 @@ --- -Title: 'sigmoid' +Title: '.sigmoid()' Description: 'The sigmoid function is an S-shaped curve typically used in binary classification problems' Subjects: - 'AI' @@ -19,7 +19,7 @@ CatalogContent:   - 'intro-to-py-torch-and-neural-networks' --- -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. +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. From 59f15ba3ee631e507de982c4502afffed471d0f7 Mon Sep 17 00:00:00 2001 From: Amy Page Date: Sat, 20 Dec 2025 12:33:15 +0000 Subject: [PATCH 3/3] Address maintainer feedback --- .../terms/sigmoid/sigmoid.md | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/content/pytorch/concepts/tensor-operations/terms/sigmoid/sigmoid.md b/content/pytorch/concepts/tensor-operations/terms/sigmoid/sigmoid.md index 8a0e107c76e..e32427c65b8 100644 --- a/content/pytorch/concepts/tensor-operations/terms/sigmoid/sigmoid.md +++ b/content/pytorch/concepts/tensor-operations/terms/sigmoid/sigmoid.md @@ -1,6 +1,10 @@ --- Title: '.sigmoid()' +<<<<<<< HEAD Description: 'The sigmoid function is an S-shaped curve typically used in binary classification problems' +======= +Description: 'Applies the sigmoid activation to each element of a tensor, mapping values to a range between 0 and 1' +>>>>>>> c428da50f (Address maintainer feedback) Subjects: - 'AI' - 'Machine Learning' @@ -19,14 +23,18 @@ CatalogContent:   - 'intro-to-py-torch-and-neural-networks' --- +<<<<<<< HEAD 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. +======= +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. +>>>>>>> c428da50f (Address maintainer feedback) -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. +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 +## Example The following example plots the sigmoid function: @@ -37,9 +45,20 @@ import torch x = torch.linspace(-10, 10, steps=400) y = torch.sigmoid(x) -plt.plot(x.numpy(), y.numpy() +plt.plot(x.numpy(), y.numpy()) plt.title("Sigmoid function") plt.xlabel("x") plt.ylabel("σ(x)") plt.show() ``` + +This example applies the sigmoid function to a tensor: + +```py +import torch + +x = torch.tensor([-1.8, -1.5, 0.0, 2.0, 4.0]) +y = torch.sigmoid(x) + +print(y) +``` \ No newline at end of file