{'fraction_non_alphanumeric': 0.017526777020447908, 'fraction_numerical': 0.0, 'mean_word_length': 4.840909090909091, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Dynamic Weighted Cross Entropy for Semantic Segmentation with Extremely Imbalanced Data

The most common loss function in semantic segmentation is the cross entropy. In the most data-balanced scene, the cross entropy can be used as a loss function to achieve good results. However, in the real scene, there are many cases where the data are extremely imbalanced. In these cases, it is difficult to obtain ideal results by using the cross entropy as the loss function. In order to solve the aforementioned problem, we propose a dynamic weighted cross entropy as the loss function for semantic segmentation. Firstly, we count the number of each category in each training batch and global data. And then a weighting method is designed to weight the cross entropy. The object which is extremely hard to classify is removed by the hard truncation. Finally, we iterate the weight in every train step. The experiment results demonstrate that our method can effectively improve the segmentation accuracy with extremely imbalanced data.