liveBook · Manning

Swish

As explained in Deep Learning with JAX

A smooth activation function discovered by automatic search and used here as the example nonlinearity in the network.

Swish is a smooth activation function used to add nonlinearity to neural-network computations. Without an activation function, stacked linear layers collapse into a single linear model, limiting classification to linearly separable problems. In JAX, import it from jax.nn and apply it to each hidden layer's outputs. section 2.4.2

Using Swish in a forward pass

A prediction function computes each hidden layer with jnp.dot(w, activations) + b, then applies swish(outputs). The final layer produces logits without another shown activation. Calling predict(params, random_flattened_image) returns a ten-element output for the example image.

How Deep Learning with JAX covers it

How deep it goes
Explains why nonlinearities matter and demonstrates the JAX call, but does not derive Swish mathematically.
Examples
Demonstrates Swish inside a multilayer prediction function applied to a flattened 28×28×1 image.
What it assumes
Assumes basic neural-network layers, weights, biases, and forward-pass computation while motivating the need for nonlinearity.
What you can do after
Apply it via JAX's jax.nn.swish function in hidden layers of a parameterized neural network.
How it connects
Connects Swish to activation functions, forward passes, neural networks, ReLU, sigmoid, hyperbolic tangent, and GELU.

Also explained in

Compare how 2 books explain Swish →

Related concepts

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