liveBook · Manning

Mean squared error

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

Mean squared error is the average of the squared differences between corresponding predicted and target numerical values.

Mean squared error (MSE) measures the average squared difference between corresponding predicted and target numerical values. Squaring makes larger pixel errors contribute more strongly to the result. section 3.5

For image optimization, subtract the target array from the rendered array, square the differences, average them across all values, and minimize the resulting scalar as the fitness score. section 3.5

Evaluating a rendered image

A compact implementation is `error = (np.square(render - target)).mean(axis=None)`. An evaluation function renders an individual, passes the image to `fitness_mse`, and returns the error as a one-element fitness tuple. section 3.5

Listing 3.21 EDL_3_5_EvoList.ipynb: The fitness and evaluate functions
def fitness_mse(render):  
    error = (np.square(render - target)).mean(axis=None)   #1
    return error
 
  def evaluate(individual):
    render = render_individual(individual)                 #2
    print('.', end='')                                     #3
    return fitness_mse(render),                            #4

Inspect the fitness and evaluation implementation used to compare rendered images with a target. section 3.5

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

How deep it goes
Defines and implements array-wide squared-error averaging, but does not derive statistical properties or discuss metric variants.
Examples
Uses rendered Mona Lisa, stop-sign, and celebrity images, plus an exercise replacing binary cross-entropy with MSE.
What it assumes
Assumes familiarity with NumPy arrays, rendered images, and evolutionary evaluation functions.
What you can do after
Apply it via NumPy to calculate image error and return that value as an evolutionary fitness score.
How it connects
Connects image rendering, fitness functions, genetic algorithms, and neuroevolution.

Also explained in

Compare how 13 books explain mean squared error →

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.