DNN Model Fine-Tuning Algorithm

From GM-RKB
(Redirected from model fine-tuning)
Jump to navigation Jump to search

A DNN Model Fine-Tuning Algorithm is a[ transfer learning algorithm is a DNN training algorithm and that creates a DNN fine-tuned model.



References

2023

  • chat
    • QUOTE: The process of fine-tuning a DNN (Deep Neural Network) involves adapting a pre-trained neural network to a new task by training it on a new dataset. The fine-tuning algorithm typically involves the following steps:
      1. Load Pre-Trained Model: The pre-trained DNN model is loaded and the weights are frozen to prevent them from changing during the fine-tuning process.
      2. Replace Last Layer(s): The final layer(s) of the pre-trained model are removed or replaced with a new set of layers that are specific to the new task. For example, if the pre-trained model was trained on an image classification task with 1000 classes, and the new task involves classifying images with only 10 classes, the final layer would be replaced with a new layer that has 10 output neurons.
      3. Train on New Dataset: The modified DNN model is then trained on the new dataset. The weights of the pre-trained layers are frozen, and only the weights of the new layers are updated during backpropagation. The learning rate for the new layers may be set to a higher value than the learning rate for the pre-trained layers to speed up the training.
      4. Monitor Performance: The performance of the model is monitored during training using a validation set. The validation accuracy is used to determine when to stop training or adjust hyperparameters, such as the learning rate or batch size.
      5. Test on Test Set: Once training is complete, the fine-tuned DNN model is evaluated on a test set to measure its accuracy and performance.
    • The goal of the fine-tuning process is to adapt the pre-trained DNN model to the new task while retaining the learned features and knowledge from the pre-training phase. By fine-tuning, the model can achieve better performance on the new task with limited data compared to training a new model from scratch.

      In summary, the fine-tuning algorithm involves replacing the final layers of a pre-trained DNN model, training the new layers on a new dataset, and monitoring performance to achieve better performance on a new task.

2021

  • (Zhang et al., 2021) ⇒ Aston Zhang, Zachary C Lipton, Mu Li, and Alexander J Smola. (2021). “Dive Into Deep Learning - 13.2 Fine Funing.” In: arXiv preprint arXiv:2106.11342.
    • QUOTE: In earlier chapters, we discussed how to train models on the Fashion-MNIST training dataset with only 60000 images. We also described ImageNet, the most widely used large-scale image dataset in academia, which has more than 10 million images and 1000 objects. However, the size of the dataset that we usually encounter is between those of the two datasets.

      Suppose that we want to recognize different types of chairs from images, and then recommend purchase links to users. One possible method is to first identify 100 common chairs, take 1000 images of different angles for each chair, and then train a classification model on the collected image dataset. Although this chair dataset may be larger than the Fashion-MNIST dataset, the number of examples is still less than one-tenth of that in ImageNet. This may lead to overfitting of complicated models that are suitable for ImageNet on this chair dataset. Besides, due to the limited amount of training examples, the accuracy of the trained model may not meet practical requirements.

      In order to address the above problems, an obvious solution is to collect more data. However, collecting and labeling data can take a lot of time and money. For example, in order to collect the ImageNet dataset, researchers have spent millions of dollars from research funding. Although the current data collection cost has been significantly reduced, this cost still cannot be ignored.

      Another solution is to apply transfer learning to transfer the knowledge learned from the source dataset to the target dataset. For example, although most of the images in the ImageNet dataset have nothing to do with chairs, the model trained on this dataset may extract more general image features, which can help identify edges, textures, shapes, and object composition. These similar features may also be effective for recognizing chairs.

    • In this section, we will introduce a common technique in transfer learning: fine-tuning. As shown in Fig. 13.2.1, fine-tuning consists of the following four steps:
      1. Pretrain a neural network model, i.e., the source model, on a source dataset (e.g., the ImageNet dataset).
      2. Create a new neural network model, i.e., the target model. This copies all model designs and their parameters on the source model except the output layer. We assume that these model parameters contain the knowledge learned from the source dataset and this knowledge will also be applicable to the target dataset. We also assume that the output layer of the source model is closely related to the labels of the source dataset; thus it is not used in the target model.
      3. Add an output layer to the target model, whose number of outputs is the number of categories in the target dataset. Then randomly initialize the model parameters of this layer.
    • # Train the target model on the target dataset, such as a chair dataset. The output layer will be trained from scratch, while the parameters of all the other layers are fine-tuned based on the parameters of the source model.
    • Fig. 13.2.1 Fine tuning.

    • When target datasets are much smaller than source datasets, fine-tuning helps to improve models’ generalization ability.