Loss Function Evaluation

Published:

Accurate tracing of grain boundaries in microscopy images is vital in material science, yet current models need more data and a more accurate loss function. In this report, we present a twofold contribution to improving grain-tracing U-nets. First, we introduce a systematic data augmentation pipeline that uses GIMP to crop each image and its corresponding ground-truth tracing into aligned sub-images. This approach expands the training set while preserving trace integrity. Second, we examine binary cross-entropy (BCE) loss and demonstrate its tendency to double-penalize slight misalignments. To address that, we develop two evaluation metrics: a binary “top-hat” criterion that rewards traces within a fixed-pixel dilation and a continuous normalized Gaussian dilation loss that smoothly interpolates reward and penalty based on distance. By constructing dilated reward masks and computing pointwise products within network outputs, we obtain loss curves that decrease monotonically over 0-300 training epochs, consistent with the trend of qualitative visual improvements. The evaluation function allows turnable tolerance through the Gaussian σ parameter. Together, these methods offer a robust framework for data generation and performance evaluation in U-net tasks.

Download Slides