liveBook · Manning

Sigmoid

As explained in Deep Learning with R, Third Edition

A sigmoid activation function maps arbitrary real-valued inputs to values in the interval from zero to one.

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

How Deep Learning with R, Third Edition covers it

How deep it goes
Defines sigmoid as a squashing function, explains its probability interpretation, and contrasts its bounded range with linear regression outputs.
Examples
Uses a sentiment-classification model whose final one-unit Dense layer applies sigmoid.
What you can do after
Apply it via Keras as a one-unit final-layer activation for binary classification and pair it with binary crossentropy.
How it connects
Connects sigmoid with activation functions, ReLU, Dense layers, binary classification, binary crossentropy, and regression.

Also explained in

Compare how 16 books explain sigmoid →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with R, Third Edition. The section links point to the parts of the book it draws on.