Improving the Efficiency of Transfer Learning Through Dynamic Determination of the Number of Layers to Freeze Based on Class Similarity
Keywords
Abstract
In this research work, a method is presented that automatically determines the number of neural network layers to be freezed during transfer learning. The proposed approach is based on the use of cosine distance between the vector representations of classes from the source and target datasets, which makes it possible to evaluate their semantic similarity and accordingly regulate the depth of layer freezing for further fine-tuning. Unlike fixed strategies, the dynamic approach provides more flexible utilization of prior knowledge and reduces the need for excessive computations. The study employs the ResNet-50 architecture and class subsets from the CIFAR-10 dataset, for which mean feature vectors were generated and cosine distance was calculated. Based on these values, the method dynamically determined how many layers of the model should be frozen and kept unchanged, and which layers require retraining. The effectiveness of the method was evaluated by comparing classical training from scratch with training using this transfer learning approach. The obtained results demonstrate that the proposed method improves generalization quality and reduces training time, highlighting the advantages of dynamically determining the number of layers to freeze. The method can be applied in tasks where rapid adaptation, limited data, and efficient resource usage are essential. The proposed technique is promising, as it effectively combines model accuracy with reduced computational costs, enabling scalability, reusability of pretrained layers, and quick integration into various application domains, making it a valuable tool for future research and practical implementations.
