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












