Skip to main content
. 2024 Mar 12;24(6):1815. doi: 10.3390/s24061815
Algorithm 1 Implementation: Few-Shot Model Compression Algorithm.
Input: Base class dataset Db, validation dataset Dval, and the novel class dataset Dn,
   the teacher network Bθt·,Cb·,Cr·, the student network Bθs·,Cs·,
   temperature parameter τ, hyperparameter α1, α2, β.
Output: The predicted value y^q of query samples in Dn
Stage 1: Teacher network pre-training
While epoch ≤ maximum number of the iteration
   A batch of images is randomly selected from Db.
   Images are fed into the backbone of the teacher network to extract the feature.
   Obtain the base class and rotation class probability values.
   Pre-train the teacher network according to Equation (4).
Stage 2: Few-shot model compression
While epoch ≤ maximum number of the iteration
   A batch of images is randomly selected from Db.
   The image is separately fed into the backbone of the teacher and the student networks to extract features.
   Obtain the base class probability values from the teacher network and the student network, respectively.
   Calibrate the feature error distribution between the student network and the teacher network according to Equation (16).
   Calculate the knowledge distillation loss function for intermediate features according to Equation (17).
   Calculate the KL divergence-based loss function between the predicted output values of the student network and the teacher network according to Equation (20).
   Calculate the cross-entropy loss function of the student network according to Equation (21).
   Train the student network according to Equation (22).
Stage 3: Few-shot model testing
While epoch ≤ maximum number of the iteration
   Images from Dn are processed through the feature extractor to obtain the feature.
   Train classifier g(·) for the novel classes.
   Test on the query set from Dn.