Automatic Image Annotation (AIA) is crucial for the establishment of image retrieval system. In this paper deep model is used for AIA task. Deep learning (DL) showed great performance in different tasks, but there are two problems called class-imbalance and weak-labeling in AIA task seriously affect the training process of deep model. Given these problems, we draw on the idea of reinforcement learning and propose dynamic loss function for model's training in this paper. An improved DenseNet trained by dynamic loss function shows superior performance in AIA task, we evaluate our method on three standard datasets, the competitive result compared with other methods shows the effectiveness of our method.