liveBook · Manning

Step function

As explained in Natural Language Processing in Action, Second Edition

A step function maps a value to one of discrete outputs according to whether it crosses a specified threshold.

A step function converts a weighted sum into a binary decision. If the sum exceeds a chosen threshold, it returns 1; otherwise, it returns 0. In a perceptron, this thresholding step determines whether the neuron fires, adding nonlinear behavior beyond linear regression. section 5.1.5

Thresholding a neuron output

For the phrase “green egg egg ham ham ham spam spam spam spam,” a weighted feature sum might be -0.76. With threshold = 0.0, Python evaluates int(y > threshold), producing 0. Changing the weights or threshold can change the decision. Use a logistic activation instead when the output should represent a continuous likelihood. section 5.1.5

>>> threshold = 0.0
>>> y = int(y > threshold)

Inspect the minimal Python implementation that applies a zero threshold to a neuron’s weighted output. section 5.1.5

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Defines thresholding and demonstrates its Python expression, stopping short of training or backward propagation.
Examples
Uses a bag-of-words phrase, random weights, a -0.76 sum, and a zero-threshold Python expression.
What it assumes
Assumes feature vectors, weights, and weighted sums while defining threshold-based activation directly.
What you can do after
Apply it via Python to turn a neuron’s numerical output into a binary prediction.
How it connects
Connects weighted sums, perceptrons, neural networks, logistic regression, and logistic activation functions.

Also explained in

Compare how 2 books explain step function →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.