The sigmoid, or logistic function, maps a real-valued score to a value between 0 and 1. Its smooth, S-shaped curve is useful when a model needs an output that can be interpreted as a probability. section 5.1.1 section 8.2.1
The sigmoid transforms a score s using 1 / (1 + e⁻ˢ). In logistic regression, s is a weighted sum of input features. section 5.1.1
Screening for enzyme inhibition
A logistic regression model can score whether a compound inhibits a cytochrome P450 enzyme. Treat the sigmoid output as the predicted probability of inhibition: below 0.5, classify the compound as a noninhibitor and keep it; at or above 0.5, classify it as an inhibitor and filter it out. section 5.1.1
During training, binary cross-entropy measures how close the predicted probability is to the true label, 0 or 1. Gradient descent adjusts the weights to reduce the loss. The sigmoid is differentiable, so its output supports gradient-based learning. section 5.1.1 section 8.2.1
Listing 8.5 Logistic Regression Model Class
x = torch.tensor([1.0, 2.0, 3.0])
w = torch.tensor([0.1, 0.2, 0.3], requires_grad=True)
b = torch.tensor(0.1, requires_grad=True)
z = torch.sum(x * w) + b
y = torch.sigmoid(z)
target = torch.tensor(1.0)
loss = torch.binary_cross_entropy(y, target)
loss.backward()
print(f"Gradient of w: {w.grad}")
print(f"Gradient of b: {b.grad}")
This PyTorch example applies torch.sigmoid to a weighted sum, computes binary cross-entropy, and calls backward() to calculate gradients for the weights and bias. section 8.2.1
Although sigmoid makes the output nonlinear in the score, a single logistic regression unit still has a linear decision boundary in the original feature space: a probability of 0.5 occurs where the weighted sum is zero. Nonlinear feature transformations or hidden layers can capture more complex relationships. section 8.2.1
For multilabel prediction, the logistic function can be applied independently to each class. For example, a molecule may inhibit any combination of five cytochrome P450 enzymes. When assembling such data, a missing inhibition record should not automatically be treated as evidence that the molecule does not inhibit the enzyme. section 5.4.2
Sigmoid outputs also act as gates in a gated recurrent unit. A reset gate controls how much previous hidden-state information is used to compute a candidate state; an update gate controls how much new information enters the final state. section 10.4.2






















