# Classification and Fast Few-Shot Learning of Steel Surface Defects with Randomized Network
## 3 Proposed Methods
### Few-Shot Learning of Defects
#### 3.2.2 Randomizing EfficientNet Features  
Unfortunately, a neural network with only one hidden layer cannot cope with deep learning networks regarding accuracy. Besides, we would like to solve the problem of few-shot learning, where we have not enough information to train our network to the new classes. What we can do, is to transfer some information from the same domain, generalize it, and use this information for the classification of the new classes. For this transfer, we propose to use the randomized back-end network to generalize previously learnt information (indirectly the feature extractors) stored in a deep backbone network.  
Basically, this can be considered as a multi-phase incremental learning mechanism. In phase 0, we fine-tune a large network (based on EfficientNet-B7) with lots of samples of the base classes. This backbone network is constructed by leaving the classification block of EfficientNet-B7, adding a global max-pooling layer, and two fully connected layers. The first has 1024 neurons, the second is the fully connected output layer with the number of classes to be trained. After training it with the available samples, this network, without the output layer, is frozen and used in the next phase as the backbone. Phase 1 is an incremental step, where we fine-tune only the back-end randomized network given the 1024 feature vectors as input. Naturally, phase 1 can be repeated many times, as new shots (or classes) appear.  
More formally, suppose we have the set of classes \(C=\{C^{B},C^{1},\ldots,C^{P}\}\), where \(C^{i}\) denotes the new classes (or equivalently class labels) appearing at step \(i\), \(P\) is the maximum number of steps in incremental learning, and \(B\) denotes the base classes with lots of samples available (\(C^{B}=C^{0}\), and preferably \(||C^{B}||\gg||C^{i}||\), for \(i\
eq B\)). Correspondingly, \(D^{B},D^{1},\ldots,D^{P}\) represent the training datasets, where \(D^{l}=(x_{s}^{i},y_{s}^{i})\) (\(s=1,\ldots,N^{i}\)), and \(x_{s}^{i}\) is the s-th example in training phase \(i\), and \(y_{s}^{i}\) is its corresponding class label.  
In phase 0, we train the backbone model for classes \(C^{B}\). In later phases, we create a support set \(D^{i}=(x_{s}^{i},y_{s}^{i})\), such that \(y_{s}^{i}\in\bigcup\{C^{i}\},l\leq i\).  
While Algorithm 1 gives the pseudo-code of this process, parameters are given in Section 6. Please note that the incremental phase (or phases) can introduce new classes, not only shots.  
```
Input: Training data in phases: \(D^{0},D^{1},D^{2},\ldots,D^{P}\); EfficientNet-B7 network;  randomized SLFN classifier Output: Trained backbone and back-end randomized classifier models
1\(i=0\)
2 Phase \(i\): Train EfficientNet-B7 for base classes \(C^{i}\) by samples in \(D^{i}\)
3 Cut top layer from EfficientNet-B7 to create backbone
4 while\(i\leq P\)do
5\(i=i+1\)
6 Randomly sample \(D^{i}\) and make the augmentation of samples
7 Use the pre-trained backbone to extract latent features for \(x_{s}^{i}\)
8 Train the randomized SLFN as given in Equation (6)
```  
**Algorithm 1**Incremental training with few shots with randomized EfficientNet features.  
The combination of EfficientNet-B7 backbone and the randomized classifier (RC) is named **EffNet+RC** in our article.