Basics Deep Learning and Neural Networks

Chapter 3
Artificial Neurons and Network Architecture

Diploma in Artificial Intelligence and Machine Learning
Basics Deep Learning and Neural Networks   •   Diploma

Artificial Neurons and Network Architecture

Introduction

Deep learning begins with a simple computational idea: a system can transform inputs into useful outputs by combining many small processing units. These units, called artificial neurons, are not literal copies of biological neurons. They are mathematical models inspired by selected features of nervous systems: receiving signals, combining them, applying a nonlinear response, and transmitting a result.

Artificial neurons are the basic components of neural networks. Their arrangement determines what a network can represent and how it processes information. This chapter develops the foundations needed to understand perceptrons, weights, biases, activation functions, layers, parameters, hyperparameters, and the universal approximation property of neural networks.

Learning Objectives

By the end of this chapter, you should be able to:

  • explain the biological inspiration for artificial neurons;
  • calculate the output of a perceptron and distinguish weights from biases;
  • explain why activation functions are necessary;
  • describe input, hidden, and output layers;
  • distinguish parameters from hyperparameters;
  • calculate the number of parameters in a dense network;
  • select suitable activation functions for common tasks;
  • explain the meaning and limitations of universal approximation;
  • identify practical and ethical issues in neural-network design.

From Biological Neurons to Artificial Neurons

A biological neuron receives electrochemical signals through dendrites, integrates these signals in its cell body, and may transmit a signal through its axon when the combined stimulation reaches an appropriate level. Connections between neurons are mediated by synapses. Some synapses increase the likelihood of firing, while others reduce it. Learning changes the strength of many synaptic connections.

The artificial-neuron analogy is deliberately simplified:

Biological conceptArtificial-neural-network analogy
Dendritic inputsFeature values entering a unit
Synaptic strengthWeight
Cell-body integrationWeighted summation
Firing thresholdBias and activation function
Axon outputNeuron output
Network of connected neuronsLayered computational graph

This analogy is useful for intuition, but it has limits. Biological neurons communicate through complex time-dependent, chemical and electrical processes. A standard artificial neuron usually performs a static numerical operation. Consequently, neural networks should be understood as engineered mathematical models, not biological simulations.

The Perceptron Model

The perceptron, introduced by Frank Rosenblatt, is one of the earliest trainable artificial-neuron models. Suppose an input vector contains n features, written as x1, x2, ..., xn. Each feature has a corresponding weight w1, w2, ..., wn. The neuron first computes a weighted sum plus a bias:

z = ∑i=1n wi xi + b

Here, z is the pre-activation value, wi is the weight associated with feature xi, and b is the bias. The weights and inputs must be compatible in scale so that their products can be added. In vector notation:

z = wᵀx + b

The output is produced by an activation function f:

ŷ = f(z)

The symbol ŷ means predicted output, not necessarily the true target.

The original step activation

A basic binary perceptron uses a step function:

f(z) = { 1, if z ≥ 0; 0, if z < 0 }

This function divides the input space into two regions. The decision boundary is given by:

wᵀx + b = 0

For two inputs, this equation describes a line; for three inputs, a plane; and in higher dimensions, a hyperplane. The perceptron therefore performs linear classification.

Worked example: a two-input perceptron

Consider a perceptron with w1 = 0.8, w2 = -0.4, and b = -0.2. For input x1 = 1 and x2 = 0,

z = (0.8)(1) + (-0.4)(0) - 0.2 = 0.6

Because z ≥ 0, the step activation produces ŷ = 1. For input x1 = 0 and x2 = 1,

z = (0.8)(0) + (-0.4)(1) - 0.2 = -0.6

The output is therefore ŷ = 0.

Weights and Biases

A weight determines how strongly a feature influences a neuron. A positive weight increases the pre-activation when the feature increases; a negative weight decreases it. A weight near zero indicates weak direct influence, although interpretation becomes more difficult when features are correlated or when many layers are present.

The bias shifts the activation function horizontally. It allows a neuron to produce a non-zero response even when all input features are zero. Without a bias, the decision boundary of a linear neuron must pass through the origin. This restriction is usually undesirable.

A bias can also be represented as a weight connected to a constant input of 1. This is mathematically equivalent, but the explicit-bias notation is clearer in most explanations.

Weights and biases are learned parameters. During training, an optimization algorithm changes them to reduce a loss function. They are not normally selected manually for a large network.

Activation Functions

An activation function maps a neuron's pre-activation to its output. Its most important role in a multilayer network is to introduce nonlinearity. If every layer performs only a linear transformation, the entire network remains equivalent to one linear transformation, regardless of how many layers it contains.

Step function

The step function is appropriate for explaining the classical perceptron, but it is rarely used in modern hidden layers because it is discontinuous and has zero derivative almost everywhere. Gradient-based learning therefore cannot adjust weights effectively through it.

Linear activation

A linear activation has the form:

f(z) = z

It is useful in the output layer of an ordinary regression model, where the prediction may take any real value. It should not be used in every layer of a deep network if nonlinear representation is required.

Sigmoid activation

The logistic sigmoid is:

σ(z) = 1 / (1 + e^(−z))

Its output lies strictly between 0 and 1. Its derivative is:

σ′(z) = σ(z)(1 − σ(z))

The sigmoid is useful for a binary probability output when paired appropriately with a binary cross-entropy loss. In hidden layers, very large positive or negative inputs produce small derivatives, causing saturation and potentially slowing learning.

Hyperbolic tangent

The hyperbolic tangent is:

tanh(z) = (ez − e^(−z)) / (ez + e^(−z))

Its output lies between −1 and 1 and is centered around zero. It can still saturate for large absolute values of z.

Rectified linear unit

The ReLU function is:

ReLU(z) = max(0, z)

Its derivative is 1 for positive z and 0 for negative z, with a conventional choice made at zero. ReLU is computationally simple and commonly used in hidden layers. A unit that remains in the negative region can stop receiving useful gradient updates; this is often called the dying-ReLU problem.

Leaky ReLU

A leaky ReLU allows a small negative slope:

f(z) = max(αz, z)

where α is a small positive constant, often selected as a hyperparameter. This can reduce the chance that units become permanently inactive.

Softmax activation

For a classification problem with K mutually exclusive classes, the softmax function converts logits into values that sum to 1:

pk = ezk / ∑j=1K ezj, k = 1, ..., K

Here, zk is the logit for class k and pk is its predicted probability. Softmax is generally used in the output layer for single-label multiclass classification. It should not automatically be used for multilabel tasks, where several classes may be independently present; sigmoid outputs are more suitable in that setting.

For numerical stability, implementations commonly subtract the largest logit before exponentiation. This does not change the resulting probabilities:

pk = ezk − m / ∑j=1K ezj − m, where m = maxj zj

Network Architecture

A neural network is a directed computational graph made of connected layers. The most common basic architecture is a feedforward network, in which information moves from input to output without cycles.

Feedforward neural network architecture Input layerHidden layerOutput layer x₁x₂xₙh₁h₂h₃hₘŷ₁ŷ₂
A feedforward neural network with input, hidden, and output layers
Figure: A feedforward neural network with input, hidden, and output layers

Figure: A fully connected feedforward network with an input layer, one hidden layer, and an output layer.

Input, hidden, and output layers

The input layer represents the features supplied to the network. It may contain one unit per feature, although the input representation can also be structured, such as an image tensor or a sequence of word vectors.

Hidden layers perform intermediate transformations. They are called hidden because their values are not directly observed as the target output. A network with one or more hidden layers can construct progressively more useful representations.

The output layer produces the task-specific prediction. Common choices include:

TaskTypical output design
Continuous regressionOne linear output
Binary classificationOne sigmoid output, or a logit used directly by a suitable loss
Single-label multiclass classificationK logits with softmax probabilities
Multilabel classificationOne sigmoid output per label

A network with no hidden layer is essentially a linear or generalized linear predictor, depending on its output function. A deep network contains multiple hidden layers, although the boundary between “shallow” and “deep” is not universally fixed.

Dense-layer equations

For layer l, let a(l−1) be the previous layer's activation vector. A dense layer computes:

z(l) = W(l)a(l−1) + b(l)

and then:

a(l) = f(l)(z(l))

If the previous layer has nl−1 units and the current layer has nl units, then W(l) has shape nl × nl−1, while b(l) has shape nl. These dimensions ensure that matrix multiplication and addition are valid.

Parameter counting

For a fully connected layer, the number of trainable parameters is:

Pl = nl nl−1 + nl = nl(nl−1 + 1)

The first term counts weights and the second counts biases. For a network, total trainable parameters are obtained by summing this quantity across all trainable layers.

Worked example: a network has 4 input features, a hidden layer of 3 units, and an output layer of 2 units. The first layer contains 3 × 4 = 12 weights and 3 biases, giving 15 parameters. The second contains 2 × 3 = 6 weights and 2 biases, giving 8 parameters. The total is 23 trainable parameters. Activation functions do not add trainable parameters unless they contain learned quantities.

Parameters and Hyperparameters

Parameters are values learned from training data, usually through gradient-based optimization. In a dense network, weights and biases are the principal parameters.

Hyperparameters are choices made before or around training rather than learned directly as ordinary weights. Examples include:

  • number of hidden layers and units;
  • learning rate;
  • batch size;
  • number of training epochs;
  • activation-function type;
  • optimizer choice;
  • regularization strength;
  • dropout rate;
  • initialization method.

The distinction is operational rather than absolute. Some advanced methods learn quantities that are traditionally treated as hyperparameters, but the ordinary distinction remains valuable for model development.

Learning and the Role of Architecture

During supervised learning, a network produces predictions and a loss function measures disagreement with target values. An optimizer uses gradients to update parameters. For a parameter θ, a basic gradient-descent update is:

θnew = θold − η ∂L/∂θ

where L is the loss and η > 0 is the learning rate. The formula assumes differentiability or a usable subgradient and a minimization objective. Backpropagation applies the chain rule efficiently to calculate gradients throughout the computational graph.

Architecture affects both representation and optimization. Increasing width gives a layer more units to combine features. Increasing depth allows successive transformations, potentially representing hierarchical structure more efficiently. However, a larger model also requires more computation, more memory, careful regularization, and sufficient data.

Weights are commonly initialized using methods such as Xavier/Glorot or He initialization. These methods aim to keep activation and gradient scales reasonably controlled, but they do not guarantee successful training. Input normalization, suitable activation functions, residual connections, normalization methods, and appropriate optimization settings may also be important.

Universal Approximation

The universal approximation theorem states, in simplified form, that a feedforward neural network with at least one hidden layer and a suitable nonconstant activation function can approximate any continuous function on a compact subset of Euclidean space to arbitrary accuracy, provided it has sufficiently many hidden units.

“Approximate” means that for a chosen tolerance, the network can make the difference between the target function and its output small under an appropriate mathematical measure. It does not mean that the network exactly represents every function, that a practical training algorithm will find the required parameters, or that a small network will be sufficient.

The theorem has several important qualifications:

  1. The target is generally assumed to be continuous on a compact domain for the classical statement.
  2. The activation must satisfy appropriate conditions; the result is not a license to use any arbitrary function.
  3. Sufficient width may be extremely large.
  4. Approximation ability does not establish generalization to unseen data.
  5. The theorem says little about computational efficiency, robustness, interpretability, or data requirements.

Universal approximation explains why even a shallow network can be highly expressive. It does not imply that depth is unnecessary. Deep architectures can represent some compositional functions with dramatically fewer units or parameters than comparable shallow architectures, and they often encode useful inductive biases for images, speech, language, and other structured data.

Illustrative Case: Predicting Equipment Failure

Background

A manufacturing company collects vibration, temperature, operating speed, and pressure measurements from industrial pumps. The maintenance team wants an early-warning classifier that identifies whether a pump is likely to fail within the next 24 hours.

Problem

The measurements have different units and scales. Failure examples are less frequent than normal-operation examples. A model that always predicts “normal” could achieve misleadingly high accuracy while being operationally useless.

Analysis

Engineers first define the prediction target and the time at which predictions are allowed to use information. Data from after a failure must not leak into the input features. Continuous features are inspected for missing values, outliers, sensor drift, and inconsistent sampling. Training, validation, and test data are separated by time or by machine where appropriate, rather than randomly mixing highly correlated observations.

Approach and solution

A small feedforward network is selected as an initial model. Four standardized measurements enter a hidden layer of 8 ReLU units. A single output produces a failure probability using a sigmoid function. The model is trained with a classification loss, and the decision threshold is selected using the relative costs of missed failures and unnecessary inspections.

The team compares the network with a logistic-regression baseline. It evaluates recall, precision, false-alarm rate, calibration, and operational cost rather than accuracy alone. Class weighting or resampling may be considered, but these choices are validated without contaminating the test set. Regularization and early stopping are used if validation performance indicates overfitting.

Outcome

In this illustrative case, the network detects nonlinear interactions—for example, a combination of high vibration and rising temperature—that the initial linear baseline misses. However, deployment is approved only after sensor-failure tests, monitoring, documentation, and human review procedures are established. The network supports maintenance decisions; it does not autonomously declare that a machine is safe or unsafe.

Learning points

The case demonstrates that architecture must follow the task. The output activation must match the prediction objective, the model must be evaluated with operationally meaningful metrics, and data leakage can make a technically impressive result invalid. A slightly less accurate model may be preferable if it is more interpretable, calibrated, stable across machines, and easier to monitor.

Challenges, Limitations, and Responsible Practice

Neural networks can overfit when they learn accidental patterns in the training data. A model may perform well on a random test split but fail after a change in sensors, users, environment, or population. Validation must therefore reflect the intended deployment conditions.

Interpretability is another challenge. A weight is not automatically a causal effect, particularly when features are correlated and information passes through many nonlinear layers. Explanatory tools can support investigation but should not be treated as infallible evidence of causation.

Data governance is essential. Practitioners should document data sources, consent or lawful basis where applicable, retention, access controls, labeling procedures, and known limitations. Sensitive applications may involve privacy, discrimination, safety, and accountability risks. Fairness should be evaluated across relevant groups, and decisions should include appropriate human oversight and appeal mechanisms.

Best practice includes establishing a simple baseline, defining success metrics before tuning, separating training and evaluation data, normalizing inputs using training-set statistics only, monitoring drift, recording model versions, testing edge cases, and planning retraining or withdrawal. Neural networks should be treated as components in sociotechnical systems rather than isolated mathematical objects.

Contemporary Developments

Modern deep learning extends the basic neuron through specialized architectures. Convolutional networks exploit local spatial structure; recurrent and state-space approaches process sequences; attention-based architectures model relationships between positions or tokens; and residual connections make very deep networks easier to optimize. These systems still rely on weighted transformations, biases, nonlinearities, and layered computation.

Contemporary practice also emphasizes transfer learning, where a model trained on broad data is adapted to a narrower task. This can reduce training cost but may transfer unwanted biases or fail under domain shift. Efficient adaptation, quantization, pruning, and hardware-aware design seek to reduce memory and energy requirements. Such developments do not remove the need for sound data, evaluation, governance, and human judgment.

Chapter Summary

Artificial neurons are mathematical processing units inspired loosely by biological neurons. A perceptron forms a weighted sum, adds a bias, and applies an activation function. Weights control feature influence, while biases shift the response and decision boundary. Activation functions such as sigmoid, tanh, ReLU, and softmax have different ranges, derivatives, and task-specific uses.

Neural networks organize neurons into input, hidden, and output layers. Dense-layer computation is expressed as z(l) = W(l)a(l−1) + b(l), followed by an activation. A fully connected layer with nl−1 inputs and nl units has nl(nl−1+1) trainable parameters. Parameters are learned from data; hyperparameters are selected to configure training and architecture.

The universal approximation theorem establishes broad expressive capacity, but not easy training, efficient representation, generalization, fairness, or reliability. Professional neural-network development therefore combines mathematical understanding with careful data practice, evaluation, monitoring, and responsible governance.

Key Terms

Artificial neuron: A mathematical unit that combines inputs, weights, and a bias before applying an activation function.

Bias: A trainable offset added to a weighted sum.

Activation function: A function that maps a neuron's pre-activation to its output.

Perceptron: A trainable linear-threshold classifier and an early artificial-neuron model.

Weight: A trainable coefficient representing the strength and direction of an input connection.

Pre-activation: The weighted sum plus bias before applying an activation function.

Logit: An unnormalized score, often transformed by sigmoid or softmax.

Input layer: The part of a network that receives feature representations.

Hidden layer: An intermediate computational layer whose activations are not directly target labels.

Output layer: The layer that produces task predictions.

Dense layer: A layer in which each unit connects to every unit in the preceding layer.

Parameter: A value learned from data, such as a weight or bias.

Hyperparameter: A configuration choice set outside ordinary parameter optimization.

ReLU: The activation max(0,z), widely used in hidden layers.

Sigmoid: A function mapping a real number to a value between 0 and 1.

Softmax: A function converting multiple logits into probabilities that sum to 1.

Backpropagation: Efficient gradient calculation using the chain rule.

Overfitting: Learning training-specific patterns that do not generalize well.

Universal approximation theorem: A result concerning the ability of suitable networks to approximate broad classes of functions.

Data leakage: Use of information during training that would not be available at prediction time.

Review Questions

Short Answer Questions

  1. What is the role of a bias in an artificial neuron?
  2. Why is a nonlinear activation function important in a multilayer network?
  3. Distinguish a parameter from a hyperparameter.
  4. When is a sigmoid output commonly used?
  5. What does a hidden layer do?

Long Answer Questions

  1. Explain the perceptron model and derive its linear decision boundary.
  2. Compare step, sigmoid, tanh, ReLU, and softmax activations, including suitable applications and limitations.
  3. Explain the flow of computation through input, hidden, and output layers using matrix notation.
  4. State the universal approximation theorem in practical terms and discuss its limitations.
  5. Describe a responsible workflow for developing a neural network for an industrial prediction task.

Analytical / Application Questions

  1. A dense layer receives 6 inputs and contains 5 units. Calculate its number of weights, biases, and total trainable parameters. Explain your calculation.
  2. Design an output layer for a problem in which an item may belong simultaneously to any of four independent categories. Justify the activation choice.
  3. A model has excellent random-test accuracy but poor performance after deployment on a new factory's machines. Analyze two possible causes and propose an evaluation or monitoring improvement.

Multiple Choice Questions with Answers

Question 1

For inputs x₁ = 2 and x₂ = 1, weights w₁ = 0.5 and w₂ = −1, and bias b = 0.5, what is the pre-activation z?

A. −1.5

B. 0.5

C. 1.5

D. 2.5

Correct Answer: B. 0.5

Question 2

Which component allows a linear neuron's decision boundary to shift away from the origin?

A. Bias

B. Batch size

C. Epoch

D. Loss label

Correct Answer: A. Bias

Question 3

Which activation is most appropriate for a single-label classification output over K mutually exclusive classes?

A. ReLU

B. Linear

C. Softmax

D. Tanh

Correct Answer: C. Softmax

Question 4

A dense layer has 4 inputs and 3 units. How many trainable parameters does it contain, including biases?

A. 7

B. 12

C. 15

D. 16

Correct Answer: C. 15

Question 5

Why are nonlinear activations needed between layers?

A. They guarantee perfect generalization.

B. They allow stacked layers to represent nonlinear functions.

C. They remove all trainable parameters.

D. They ensure every output is a probability.

Correct Answer: B. They allow stacked layers to represent nonlinear functions.

Question 6

Which is a hyperparameter rather than an ordinary dense-layer parameter?

A. A weight

B. A bias

C. A learning rate

D. A learned logit

Correct Answer: C. A learning rate

Question 7

Which output design is generally suitable for multilabel classification with four independent labels?

A. One softmax output with four classes

B. Four sigmoid outputs

C. One linear output only

D. One step output with no training

Correct Answer: B. Four sigmoid outputs

Question 8

What does the universal approximation theorem primarily concern?

A. Guaranteed fast training

B. Guaranteed fairness

C. Approximation of broad classes of functions by suitable networks

D. Automatic selection of hyperparameters

Correct Answer: C. Approximation of broad classes of functions by suitable networks

Question 9

A network has 4 input features, a hidden layer of 3 units, and 2 output units. How many dense-layer parameters are there in total?

A. 14

B. 20

C. 23

D. 26

Correct Answer: C. 23

Question 10

Which practice helps prevent evaluation results from being inflated by future information?

A. Using data leakage deliberately

B. Separating data according to prediction-time availability

C. Removing the output layer

D. Using only linear activations

Correct Answer: B. Separating data according to prediction-time availability

Basics Deep Learning and Neural Networks
Chapter 3 of 14