datarekha
Deep Learning Easy Asked at GoogleAsked at MetaAsked at Amazon

What does a single artificial neuron (perceptron) actually compute?

The short answer

A neuron takes a weighted sum of its inputs, adds a bias, and passes the result through an activation function. The weights encode learned feature importance, the bias shifts the decision boundary, and the activation introduces the non-linearity needed for complex mappings.

How to think about it

A neuron computes a two-step operation:

  1. Linear combinationz = w · x + b where w is the weight vector, x is the input vector, and b is the scalar bias.
  2. Activationa = f(z) where f is a non-linear function such as ReLU or sigmoid.

Stacking neurons into layers lets the network compose these operations: each layer re-represents the input in a new space, and the activation function is what prevents successive linear layers from collapsing.

import torch
import torch.nn as nn

# A single neuron: 4 inputs → 1 output
neuron = nn.Linear(4, 1)          # computes z = Wx + b
output = torch.sigmoid(neuron(x)) # applies activation f(z)

The bias term is critical — without it the decision hyperplane is forced through the origin and the neuron cannot fit many real patterns.

The weight w_i roughly measures “how much does input feature i matter?” Positive weights amplify; negative weights suppress; near-zero weights ignore.

Learn it properly Activation functions

Keep practising

All Deep Learning questions

Explore further

Skip to content