🧠 DEEP LEARNING FUNDAMENTALS

Understanding Feedforward Neural Networks From Scratch

Feedforward Neural Networks (FNNs) are the foundation of modern deep learning. In this guide, you'll learn how data flows through layers, how weights and activations work, and how these networks actually learn.

| By Affordable AI, Nagpur

Input Layer Hidden Layer Output Layer

What is a Feedforward Neural Network?

A Feedforward Neural Network (FNN) is the simplest type of artificial neural network where information moves in only one direction — forward — from the input layer, through hidden layers, to the output layer. There are no loops or cycles, unlike Recurrent Neural Networks (RNNs).

FNNs form the backbone of many machine learning applications including image classification, spam detection, credit scoring, and medical diagnosis. Understanding FNNs is the first real step toward mastering deep learning.

Why "Feedforward"?

The name comes from how data travels: it is "fed forward" from input nodes, through one or more hidden layers, to the output — with no feedback connections sending information backward during inference.

Core Structure

Architecture of a Feedforward Network

Every FNN is built from three types of layers, each playing a distinct role.

🔵

Input Layer

Receives raw features (pixels, numbers, encoded text) and passes them to the network. One neuron per input feature.

🟢

Hidden Layer(s)

Performs weighted computations and applies non-linear activation functions to learn complex patterns in data.

🟣

Output Layer

Produces the final prediction — a class label, probability score, or continuous value depending on the task.

Input Hidden 1 Hidden 2 Output

Fig 1: A fully-connected feedforward network with two hidden layers

The Math

How Forward Propagation Works

Each neuron computes a weighted sum of its inputs, adds a bias, and passes the result through an activation function:

z = (w1 × x1) + (w2 × x2) + ... + (wn × xn) + b a = activation(z)

Where w = weights, x = inputs, b = bias, and a = the neuron's output (activation). This process repeats layer by layer until the final output is produced.

Non-Linearity

Common Activation Functions

Activation functions allow networks to learn complex, non-linear relationships in data.

σ

Sigmoid

Squashes output between 0 and 1. Useful for binary classification but prone to vanishing gradients.

R

ReLU

Outputs 0 for negative inputs and the input itself for positive values. Fast and widely used in hidden layers.

T

Tanh

Similar to sigmoid but outputs between -1 and 1, giving zero-centered gradients.

S

Softmax

Converts output values into probabilities that sum to 1 — ideal for multi-class classification.

Learning Process

Training via Backpropagation

Training a feedforward network involves adjusting weights and biases so predictions get closer to actual values. This happens in three repeated steps:

1. Forward Pass

Input data passes through the network to generate a prediction.

2. Loss Calculation

The difference between the predicted output and the actual target is measured using a loss function such as Mean Squared Error or Cross-Entropy Loss.

3. Backward Pass (Backpropagation)

The error is propagated backward through the network using the chain rule of calculus, calculating how much each weight contributed to the error.

4. Weight Update

An optimizer (like Gradient Descent or Adam) updates the weights to reduce the loss:

// Gradient Descent update rule w_new = w_old - (learning_rate × gradient)
Hands-On

A Simple FNN in Python (Keras)

import tensorflow as tf from tensorflow.keras import Sequential from tensorflow.keras.layers import Dense model = Sequential([ Dense(64, activation='relu', input_shape=(20,)), Dense(32, activation='relu'), Dense(1, activation='sigmoid') ]) model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy']) model.fit(X_train, y_train, epochs=20, batch_size=32)
Comparison

FNN vs CNN vs RNN

Network TypeData FlowBest For
Feedforward (FNN)One direction onlyTabular data, basic classification
Convolutional (CNN)Spatial, one directionImages, video
Recurrent (RNN)Sequential, with memory loopsText, time-series
Real World

Applications of Feedforward Networks

📧

Spam Detection

Classifying emails as spam or not spam using text-based features.

💳

Credit Scoring

Predicting loan default risk from applicant financial data.

🏥

Medical Diagnosis

Predicting disease presence from patient test results.

🛒

Recommendation

Basic user-item scoring for product recommendations.

Trade-offs

Advantages & Limitations

Advantages

  • Simple architecture, easy to implement
  • Effective for structured/tabular data
  • Fast training on smaller datasets
  • Foundation for more advanced architectures

❌ Limitations

  • Cannot capture sequential/temporal patterns
  • No spatial awareness (unlike CNNs)
  • Can overfit without regularization
  • Struggles with very high-dimensional raw data