# BWLM: A Balanced Weight Learning Mechanism for Long-Tailed Image Recognition
## 1 Introduction  
At present, the application of deep neural networks [1; 2; 3; 4] has been popularized in various fields [5; 6; 7; 8; 9; 10], but the achievements of deep neural networks greatly rely on the availability of real-world annotated datasets [11; 12; 13; 14]. Such data often follow a long-tailed distribution [15; 16; 17; 18], where the quantity or cardinality of each type of data is severely imbalanced [14; 19; 20]. In fact, rare classes are equally important in recognition tasks. For example, in autonomous driving, vehicles and pedestrians are the common classes with more available samples, but animals crossing the road also need to be detected for safety reasons. [14; 21]. Another sample is that the common and rare species should have the same importance in animal recognition. [22]. This has sparked in-depth research in the field of deep neural networks on long-tailed image recognition, with the aim of achieving high accuracy averaging across all classes [17]. Due to having much more training data for common classes than rare classes, the training loss is dominated by common classes [17]. Therefore, in the naive models without any strategy, the accuracy of common classes is always higher than rare classes. To alleviate the challenges posed by the training data in the long-tailed problem and balance various classes [23; 24], existing research has mainly employed three types of strategies: resampling,loss function engineering, and stage-wise training. In resampling, many methods have been proposed to balance the data distribution of each class by upsampling rare classes, downsampling common classes, or both [25; 26; 27]. In loss function engineering, the loss function is influenced by assigning low weights to common classes or high weights to rare classes, which has been widely adopted before [28; 29]. However, multiple research studies have shown that artificially dividing weights can lead to poor training performance [30]. Therefore, there have been methods for implicitly defining common and rare classes, focusing on effective samples, sample difficulty, etc. [31; 32]. In stage-wise training, some methods use transfer learning to learn rare classifiers based on the features of common classes [33; 34; 35; 36]. Research has shown that the decoupling of feature learning and classifier learning is superior to traditional integrated training models [2]. The estimation of the long-tailed data using ordinary loss functions may lead to bias toward common classes. The current balanced weighted loss function either focuses on common classes or rare classes, which prompts us to explore balancing loss functions that simultaneously reduce the bias of common classes and increase the bias of rare classes. In addition, the naive training model has a high weight bias towards common classes, prompting us to explore further balancing network weights between classes. To better balance common classes and rare classes, we train the model in two stages, as shown in Figure 1. Considering the effect of feature learning and decoupling training of classifier learning on long-tailed image recognition, we decide to transfer the feature learning from the first stage to the second stage, which enables the second stage to inherit the weights from the first stage. In the second stage, we propose the Balanced Focal Softmax (BFS) loss function that considers both common and rare class weights by combining a loss function that reduces redundancy of the common classes with a loss function that increases attention to rare classes. In order to better balance network weights between classes, we also propose a Balanced Weight Learning Mechanism (BWLM) that balances network weights in the norm. We adopt the weight decay for \"punishing large weights and learning small weights\" to further balance the weights of common and rare classes in the BFS loss function. We summarize the main contributions as follows:  
* We propose the BFS loss function that combines the weight balance characteristics of common and rare classes.