# Wheel Hub Defects Image Recognition Base on Zero-Shot Learning
## 4 Method
### Domain Adaption Strategy  
After training, projection domain shift may occur between the mapped semantic descriptors and the image features of the unseen classes. This is due to data from unseen classes not being used in the training phase, so regularized models have poor generalization ability to unseen classes. Therefore, we have to use test data from the unseen defect to adjust the mapping semantic descriptor to fit the unseen defects.  
Given the mapping descriptors of unseen classes stack vertically in the form of a matrix \(A\in R^{n_{u}\times d}\), where \(n_{u}\) stands for the number of unseen classes, and \(d\) means the dimension of semantic descriptor space.  
Suppose \(U\in R^{n_{u}\times d}\) is the test data set for the unseen class, and \(O_{u}\) represents the number of test samples from the unseen class. To accommodate the mapped descriptors, a point-to-point correspondence between the descriptors and test data is used, which is represented as a matrix \(C\in R^{n_{u}\times o_{u}}\). The rows of \(U\) need to be rearranged so that each row of the revised matrix corresponds to the row in a\(A\), which is achieved by minimizing the loss function Equation (5).  
\[L_{3}=\left\|CU-A\right\|_{F}^{2} \tag{5}\]  
\(L_{3}\) can force \(CU\) to generate adaptive semantic descriptors. However, there is still the problem that a sample may correspond to more than one descriptor in \(A\), which means that it will actually result in corresponding to more than one category of test samples. To avoid this problem, by using group-Lasso [42], an additional group-based regularization function \(L_{4}\) was conducted.  
\[L_{4}=\sum_{j}\sum_{c}\left\|\left[C\right]l_{c}j\right\|_{2} \tag{6}\]  
where \(l_{c}\) means the index corresponds to those rows in the unseen class. So \(\left[C\right]l_{c}j\) stands for a vector consisting of an index of rows \(l_{c}\) and columns \(j\). Since \(C\) is a correspondence matrix, certain constraints can be applied to solve the deviation of sample number between semantic space and feature space for unseen classes. Therefore, the domain adaptive optimization problem can be expressed as follows Equation (7):  
\[\min_{c}\{L_{3}+\lambda_{g}L_{4}\}\quad s.t.\quad\ C\geq 0,\quad\ C1_{O_{u}}=1_{ u_{u}},\quad C^{T}1_{u_{u}}=\frac{n_{u}}{o_{u}}1_{o_{u}} \tag{7}\]  
where \(\lambda_{g}\) balances the weight of loss function \(L_{4}\). The above optimization problems are all convex functions, which can be effectively settled by the conditional gradient method [43], and the method requires solving the linear function on the constraint \(C\in D=\left\{C:C\geq 0,\quad C1_{o_{u}}=1_{n_{u}},\quad C^{T}1_{u_{u}}=\frac{n_{u}}{o_{u}} \;1_{o_{u}}\right\}\) as an intermediate step, as shown in Algorithm 1. using the Simplex Formulation [44] in EMD [45], the variable \(C_{d}\) in Algorithm 1 could be easily obtained [46].  
```
Initialize:\(C_{0}=\frac{1}{n_{o_{u}}}1_{n_{u}\times o_{u}}\), \(t=1\) Repeat \(C_{d}=\text{argmin}Tr(\
abla_{C=C_{0}}(L_{3}+\lambda_{g}L_{4})^{T}C)\), \(s.\)\(t.\)\(C\in D\) \(C_{1}=C_{0}+\alpha(C_{d}-C_{0})\), \(for\)\(\alpha=\frac{2}{1+2}\) \(C_{0}=C_{1}\) and \(t=t+1\) Until Convergence Output:\(C_{0}=\underset{C}{\text{argmin}}\{L_{3}+\lambda_{g}L_{4}\}\)\(s.\)\(t.\)\(C\in D\)
```  
**Algorithm 1**Conditional Gradient Method  
Algorithm 1 was used to obtain the final solution of the corresponding matrix \(C_{0}\) and to check it. Given a test sample, we assigned the class correspondence to the maximum value of the corresponding variable and did the same for all test samples. The semantic descriptors of unseen classes were acquired by averaging features of the related classes, and then adaptive semantic descriptors were stacked vertically in the matrix \(A^{\prime}\).