ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing
ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing

All Courses

Introduction to Neural Networks
Chapter 1: Foundations of Neural Networks
From Biological to Artificial Neurons
Weights and Biases: The Network's Parameters
Activation Functions: Introducing Non-Linearity
Structuring Networks: Layers and Connections
A Simple Feedforward Network Example
Practice: Calculating Neuron Output
Quiz for Chapter 1
Chapter 2: Preparing Data for Neural Networks
Understanding Input Data Representation
Feature Scaling: Normalization and Standardization
Handling Categorical Data: Encoding Techniques
Creating Data Batches for Training
Splitting Data: Training, Validation, and Test Sets
Hands-on Practical: Preprocessing Sample Data
Quiz for Chapter 2
Chapter 3: Forward Propagation: Generating Predictions
The Flow of Information in a Network
Linear Transformation: Weighted Sum Calculation
Applying Activation Functions Layer-wise
Matrix Operations for Efficient Computation
Calculating the Final Output Prediction
Hands-on Practical: Implementing Forward Propagation
Quiz for Chapter 3
Chapter 4: Training: Backpropagation and Gradient Descent
Measuring Performance: Loss Functions
The Concept of Gradient Descent
Backpropagation: Calculating Gradients Efficiently
Updating Weights and Biases
Learning Rate and Its Importance
Stochastic Gradient Descent (SGD) and Variants
Practice: Calculating Gradients Manually
Quiz for Chapter 4
Chapter 5: Building and Training a Basic Neural Network
Setting up the Network Architecture
Initializing Weights and Biases
The Training Loop Structure
Implementing the Training Step
Monitoring Training Progress
Introduction to Deep Learning Frameworks (TensorFlow/PyTorch)
Hands-on Practical: Training a Simple Classifier
Quiz for Chapter 5
Chapter 6: Improving Network Performance and Generalization
Understanding Overfitting and Underfitting
The Role of Validation Sets
Regularization Techniques: L1 and L2
Dropout: Randomly Deactivating Neurons
Early Stopping: Halting Training Optimally
Hyperparameter Tuning Strategies
Practice: Applying Regularization
Quiz for Chapter 6

Calculating the Final Output Prediction

At the output layer, a neural network produces its ultimate prediction, y^\hat{y}y^​. This is the final stage of processing for input data, which involves linear transformations and non-linear activations. Operations within the output layer are similar to those in hidden layers, but the resulting output is specifically tailored to the problem being addressed.

Let's denote the activations from the last hidden layer (or the input layer, if there are no hidden layers) as A[L−1]A^{[L-1]}A[L−1]. To get the output prediction A[L]A^{[L]}A[L], we perform two final steps:

  1. Calculate the Weighted Sum for the Output Layer: Just like in the hidden layers, we compute the linear combination of the inputs to this layer (A[L−1]A^{[L-1]}A[L−1]), using the output layer's weights (W[L]W^{[L]}W[L]) and biases (b[L]b^{[L]}b[L]).

    Z[L]=W[L]A[L−1]+b[L]Z^{[L]} = W^{[L]} A^{[L-1]} + b^{[L]}Z[L]=W[L]A[L−1]+b[L]

    Here, Z[L]Z^{[L]}Z[L] represents the pre-activation values for the output layer neurons. The dimensions of W[L]W^{[L]}W[L], b[L]b^{[L]}b[L], and consequently Z[L]Z^{[L]}Z[L] depend on the number of neurons in the last hidden layer and the number of neurons in the output layer. The number of output neurons is determined by the task: one neuron for binary classification or regression, and CCC neurons for multi-class classification with CCC classes.

  2. Apply the Output Layer Activation Function: The choice of activation function g[L]g^{[L]}g[L] for the output layer is significant because it formats the final output A[L]A^{[L]}A[L] into the desired prediction format.

    A[L]=g[L](Z[L])A^{[L]} = g^{[L]}(Z^{[L]})A[L]=g[L](Z[L])

    This final activation A[L]A^{[L]}A[L] is the network's prediction, which we often denote as y^\hat{y}y^​.

    The final step in forward propagation involves applying a linear transformation and an activation function specific to the output layer to produce the network's prediction, y^\hat{y}y^​.

Choosing the Right Output Activation

Unlike hidden layers where ReLU is a common choice, the output layer's activation function (g[L]g^{[L]}g[L]) depends directly on the nature of the prediction task:

  • Regression: If the network needs to predict a continuous numerical value (like predicting house prices), a linear activation function is typically used. This means the output is simply the weighted sum: A[L]=Z[L]A^{[L]} = Z^{[L]}A[L]=Z[L]. The output can range from −∞-\infty−∞ to +∞+\infty+∞.
  • Binary Classification: For tasks where the output is one of two classes (e.g., spam or not spam, 0 or 1), the Sigmoid function is used. It squashes the output Z[L]Z^{[L]}Z[L] into the range (0, 1), which can be interpreted as the probability of the positive class. y^=A[L]=σ(Z[L])=11+e−Z[L]\hat{y} = A^{[L]} = \sigma(Z^{[L]}) = \frac{1}{1 + e^{-Z^{[L]}}}y^​=A[L]=σ(Z[L])=1+e−Z[L]1​
  • Multi-class Classification: When classifying among more than two mutually exclusive classes (e.g., identifying digits 0-9), the Softmax function is the standard choice. It takes the vector Z[L]Z^{[L]}Z[L] (where each element corresponds to a class) and converts it into a probability distribution. Each element in the output vector A[L]A^{[L]}A[L] is between 0 and 1, and the sum of all elements is 1. y^i=Ai[L]=softmax(Z[L])i=eZi[L]∑j=1CeZj[L]for i=1,...,C\hat{y}_i = A^{[L]}_i = \text{softmax}(Z^{[L]})_i = \frac{e^{Z^{[L]}_i}}{\sum_{j=1}^{C} e^{Z^{[L]}_j}} \quad \text{for } i=1, ..., Cy^​i​=Ai[L]​=softmax(Z[L])i​=∑j=1C​eZj[L]​eZi[L]​​for i=1,...,C Here, CCC is the number of classes, and y^i\hat{y}_iy^​i​ represents the predicted probability that the input belongs to class iii.

Understanding the Prediction (y^\hat{y}y^​)

The final output vector A[L]A^{[L]}A[L], which we call y^\hat{y}y^​, contains the network's prediction(s) based on the input XXX.

  • For regression, y^\hat{y}y^​ is a single continuous value (or multiple values if predicting multiple targets).
  • For binary classification, y^\hat{y}y^​ is a single value between 0 and 1, representing P(class=1∣X)P(\text{class}=1 | X)P(class=1∣X). You might apply a threshold (e.g., 0.5) to convert this probability into a definite class label (0 or 1).
  • For multi-class classification, y^\hat{y}y^​ is a vector of probabilities, one for each class. The class with the highest probability is typically chosen as the final predicted label.

With the calculation of y^\hat{y}y^​, the forward propagation process is complete. The network has taken an input XXX and produced a prediction y^\hat{y}y^​ by passing information through its layers, applying linear transformations and activation functions along the way. This prediction can now be compared to the true label yyy using a loss function, which is the first step in the training process (covered in the next chapter).

  • Deep Learning, Ian Goodfellow, Yoshua Bengio, and Aaron Courville, 2016 (MIT Press) - Covers the theoretical foundations of neural networks, including detailed explanations of forward propagation, various output units (linear, sigmoid, softmax), and their mathematical formulations.
  • Neural Networks and Deep Learning (Deep Learning Specialization, Course 1), Andrew Ng, Kian Katanforoosh, Younes Bensouda Mourri, 2017 (DeepLearning.AI) - Provides an accessible introduction to neural network fundamentals, clearly explaining forward propagation, activation functions, and the purpose of different output layers in a practical context.

© 2026 ApX Machine Learning