An activation function applies a nonlinear transformation to a neuron's output. Without it, a stack of linear layers would remain equivalent to a single linear layer. ReLU (max(0, x)) is the most common in hidden layers; sigmoid and softmax are mostly used at the output for probabilities.
Example
nn.ReLU()