A sigmoid activation function squashes arbitrary real-valued inputs into the interval [0, 1]. In binary classification, this scalar output can be interpreted as the probability of the positive class. section 4.1.3
Binary classification output
A model for sentiment classification can use sigmoid only in its final one-unit Dense layer: layer_dense(1, activation = "sigmoid"). The intermediate layers use ReLU, while the sigmoid output supplies a score between zero and one. With this output, binary_crossentropy is the matching loss. section 4.1.3 section 4.1.7
Activation functions add nonlinearity; without one, stacked Dense layers would still represent only linear transformations. Sigmoid is therefore useful for bounded classification outputs, but it constrains regression predictions to values between zero and one. section 4.1.3 section 4.3.3
Listing 4.4 Model definition
model <- keras_model_sequential() |> layer_dense(16, activation = "relu") |> layer_dense(16, activation = "relu") |> layer_dense(1, activation = "sigmoid")
Inspect the complete three-layer model definition and its final sigmoid-enabled Dense layer. section 4.1.3















