liveBook · Manning

Generalization

As explained in Evolutionary Deep Learning: Genetic algorithms and neural networks

Generalization is a model's ability to perform well across environments or data conditions beyond those directly optimized during development.

Generalization is the ability of a learned model or evolved routine to perform beyond the particular data or environment used to optimize it. A model can appear highly successful during training while merely memorizing its training data; declining validation performance exposes that mismatch. Generalization is checked by separating training data from test or validation data, or by running an agent in environments it did not optimize against. section 7.1.1 section 12.4

Capacity and training design affect the trade-off. A single CNN with more than 6 million parameters memorizes a reduced dataset: training accuracy approaches 100% while validation accuracy worsens. Adding pooling sharply reduces parameter count, and batch normalization is inserted to improve generalization; increasing validation accuracy alongside decreasing loss signals improvement, though memorization can remain. section 7.1.1

Techniques shown for improving behavior beyond the immediate training cases include:

  • Hold out validation or test data to distinguish memorization from useful performance. section 7.1.1
  • Use dropout, which randomly disables nodes on each training iteration to reduce memorization and keep training and validation loss more consistent. section 8.1.4
  • Use batch normalization between convolutional layers; it normalizes each feature map using its mean and variance, keeps values centered near zero, and reduces vanishing or exploding gradients. section 8.1.4
  • Evolve against multiple environments simultaneously, so random environment selection during evaluation favors routines that search for food across them. section 12.4

CNN: memorization versus validation

A Keras CNN begins with a 64-filter 3×3 convolution, flattening, a 128-unit dense layer, and ten outputs. Its large parameter count can memorize a reduced dataset. A revised version adds BatchNormalization and 2×2 max pooling after convolution, reducing the model to about 1.6 million parameters and producing better, though imperfect, validation behavior over ten epochs. section 7.1.1

Artificial ant across trails

An evolved ant that is tested unchanged on two added trail environments performs poorly. Loading all three trails before evolution causes resets to choose environments at random, requiring a routine that works across varied food layouts. The setup retains low-level movement and sensing functions while evolution assembles higher-level logic. section 12.4

Generalization is not always the desired outcome. When the goal is to identify a very specific data set, memorization may be useful. Likewise, evolving a single equation across two environments without reusable instinct operators may converge only near a solution for one environment; reusable functions can reduce the complexity and choices faced during evolution. section 7.1.1 section 12.3.3

Listing 12.30 EDL_12_4_DEAP_Ant.ipynb: Generalizing the ant
ant.clear_matrix()                                #1
 
with  open("santafe_trail1.txt") as trail_file:
  ant.add_matrix(trail_file)                      #2
 
with  open("santafe_trail2.txt") as trail_file:
  ant.add_matrix(trail_file)                      #2
 
with  open("santafe_trail3.txt") as trail_file:
  ant.add_matrix(trail_file)                      #2
 
GENERATIONS = 100 #@param {type:"slider", min:10, max:1000, step:5}
algorithms.eaSimple(pop, toolbox, 0.5, 0.2, 
 GENERATIONS, stats, halloffame=hof)            #3

This runnable setup loads three trail environments and reruns evolution, making the training distribution explicitly span multiple environments. section 12.4

How Evolutionary Deep Learning: Genetic algorithms and neural networks covers it

How deep it goes
Works through CNN regularization and multi-environment genetic-programming experiments, while noting imperfect results and a failed equation-evolution attempt.
Examples
Uses a high-capacity CNN, a pooled normalized CNN, equation evolution across two environments, and an artificial ant on three trails.
What it assumes
Assumes familiarity with CNN layers and evolutionary agents while providing runnable model and simulator configuration.
What you can do after
Apply it via Keras and DEAP by comparing validation behavior and evolving routines across multiple environments.
How it connects
Connects generalization to overfitting, validation data, dropout, batch normalization, pooling, convolutional neural networks, and genetic programming.

Also explained in

Compare how 13 books explain generalization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Evolutionary Deep Learning: Genetic algorithms and neural networks. The section links point to the parts of the book it draws on.