How to avoid overfitting on a simple feed forward network
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Overfitting happens when a network learns the training set too specifically and fails to generalize to new examples. A simple feed-forward network can still overfit if the dataset is small, noisy, or if the model is trained too long with too much capacity.
Recognize the Pattern First
The classic symptom is a widening gap between training and validation metrics. Training loss keeps falling, but validation loss flattens out or starts rising. That means the model is memorizing details that do not help on unseen data.
A good workflow starts with a validation set and a training curve. Without those, you are guessing.
Start with a Smaller Network
Many beginners respond to weak results by adding more layers and more units. That often makes overfitting worse. A smaller model is easier to train and harder to memorize with.
Here is a compact Keras example for binary classification:
This model is intentionally modest. One hidden layer is often enough for tabular data baselines.
Use Validation Data and Early Stopping
The most practical anti-overfitting tool is early stopping. Train for many epochs, but stop once validation loss stops improving.
This prevents the model from drifting into memorization late in training. It is cheap, easy to add, and should be part of almost every baseline experiment.
Regularize Instead of Guessing
Two regularization methods work especially well for simple feed-forward networks:
- '
Dropout, which randomly disables a fraction of activations during training' - '
L2weight decay, which discourages large weights'
Both are already present in the example above. The goal is not to make the model weak. The goal is to make it less brittle.
Do not overdo either one. Very aggressive dropout or regularization can cause underfitting, where both training and validation performance stay poor.
Data Quality Often Matters More Than Architecture
If your model overfits badly, the dataset may be the real bottleneck. Typical causes include:
- too few samples
- label noise
- duplicated records
- leakage between train and validation sets
For tabular data, better splitting and cleaning usually help more than stacking extra dense layers. If your dataset contains near-duplicates across training and validation, the validation score can look good during experimentation and then collapse in production.
Standardization also matters. Dense networks are easier to train when numeric features are scaled consistently, which is why the example uses StandardScaler.
A Good Baseline Strategy
A disciplined process usually works better than a clever network:
- start with one or two dense layers
- keep the hidden width moderate
- scale the inputs
- add a validation split
- use early stopping
- only then tune dropout, weight decay, and layer size
That order helps you tell whether the improvement comes from better generalization or just more capacity.
Common Pitfalls
- Evaluating only on the training set and assuming a high accuracy means the model is good.
- Making the network deeper before checking whether the data split is sound.
- Applying scaling before the train-test split, which leaks information from the test set.
- Using too much dropout and then mistaking underfitting for overfitting.
- Training for a fixed large number of epochs without early stopping or validation monitoring.
Summary
- Overfitting shows up when training performance improves while validation performance worsens.
- A smaller dense network is often a stronger baseline than a larger one.
- Early stopping is one of the simplest and most effective defenses.
- Use regularization thoughtfully, not automatically.
- Clean splits, scaled inputs, and good data quality usually matter as much as model architecture.

