Kernel size is the spatial extent of a convolutional filter, expressed as dimensions such as 3×3. In a CNN, it is a layer hyperparameter that shapes how convolution processes image data. section 7.1.1 section 7.2
Kernel size appears in several practical architecture decisions:
- Keras passes it to Conv2D as a tuple, such as (3, 3), alongside the filter count and padding. section 7.1.1
- Architecture encodings store convolutional kernel dimensions as genes alongside the number of filters or neurons. section 7.2
- Pooling has its own spatial-size settings, allowing experiments to compare kernel-size changes with pooling changes or additional convolutional layers. section 7.1.2 section 7.1.1
- Evolutionary mutation can replace convolutional and pooling dimensions with random values constrained by configured minimum and maximum ranges. section 7.4
A kernel size in a Keras layer
The layer Conv2D(64, (3, 3), activation='relu', padding='same', input_shape=(28, 28, 1)) uses a 3×3 kernel with 64 filters. In the evolutionary encoding, the corresponding convolution block stores the filter count followed by two kernel dimensions, for example [-1, 37, 5, 2]. section 7.1.1 section 7.2
Listing 7.18 EDL_7_4_Mutation_CNN.ipynb: The mutate function
def mutate(part, layer_type):
if layer_type == CONV_LAYER and len(part)==CONV_LAYER_LEN: #1
part[1] = int(part[1] * random.uniform(.9, 1.1)) #2
part[2] = random.randint(min_kernel, max_kernel) #3
part[3] = random.randint(min_kernel, max_kernel) #3
elif layer_type == POOLING_LAYER and len(part)==POOLING_LAYER_LEN: #1
part[1] = random.randint(min_kernel, max_kernel) #3
part[2] = random.randint(min_kernel, max_kernel) #3
elif layer_type == DENSE_LAYER and len(part)==DENSE_LAYER_LEN: #1
part[1] = int(part[1] * random.uniform(.9, 1.1)) #2
else:
error = f"mutate ERROR {part}" #4
raise Exception(error)
return part
Inspect the mutation implementation that changes convolutional kernel dimensions within configured bounds while validating the layer block. section 7.4



