# Face Gender and Age Classification Based on Multi-Task, Multi-Instance and Multi-Scale Learning
## 2 Facial Gender and Age Classification Based on MML and DRF
### DRF Model  
In general, gender recognition is easier than age grouping. In the facial age grouping field, due to the existence of facial gender factors, the facial age grouping in the feature space is different, which makes it difficult to construct a facial age classifier with high accuracy. Therefore, by putting a gender and age recognition study together and usingfacial gender as an implicit condition to divide the face data space, we propose a face age grouping method based on conditional random forest. The implementation steps for the DRF model are as follows:  
Step 1. A face gender classifier based on random forest is developed by using all face data. MMFL was used to extract the robust features \(y\), and \(T^{G}\) was used to estimate face gender \(g\), where \(T^{G}\) training uses uncertainty measures:  
\[H(y)=-\sum_{g}p(g|y)\log_{2}(p(g|y)) \tag{6}\]  
The uncertainty measure guides each node to choose the best binary test from the candidate library of binary tests to ensure that the current node can be divided into two sub-nodes with reduced uncertainty. Face gender is stored on each leaf node \(l\) of \(T^{G}\) with a Gaussian model:  
\[p(g|l(y))=N(g;\bar{g_{l}};\sigma_{l}) \tag{7}\]  
where \(\bar{g_{l}}\) and \(\sigma_{l}\) are the mean and covariance, respectively. While Equation (7) models the probability for a sample feature \(y\) ending in a leaf \(l\), the gender probability of the forest is obtained by averaging over all trees:  
\[p(g|y)=\frac{1}{M}\sum_{m}p(g|l_{m}(y)) \tag{8}\]  
where \(l_{m}\) is the corresponding leaf for a tree and \(M\) is the number of trees. Step 2. We classified the face dataset according to face gender and trained a series of gender-conditional random forest decision trees. Each decision tree in a conditional random forest \(\left\{T^{S}(\Omega_{n})\right\}_{n=1}^{2}\) is independently trained by using the same method. In order to build each decision tree \(T^{S}_{t}(\Omega_{n})\), first, randomly select images from the corresponding data subset \(S_{\Omega_{n}}\) to form a training dataset; then, randomly extract a series of sub-features \(\left\{y_{i}=(a_{i},l_{i})\right\}\) from each training image feature \(y\), where \(a_{i}\) is the face age class and \(l_{i}=\left\{l_{i}^{1},l_{i}^{2},\cdots,l_{i}^{F}\right\}\) is a set of sub-features selected from \(y\); finally, the selected sub-features are used to split the decision tree nodes to generate the final decision tree. We used a Neurally Connected Split Function (NCSF) splitting model to reinforce the learning capability of a splitting node by combining the Information Gain of the decision tree and the loss function of the deep network model [24]. The connection function \(f_{n}\) of a hidden layer in MMFL is used to enhance the conditional feature presentation \(y\) of a face sample; meanwhile, the enhanced feature presentation is used as the node feature selection of the network-enhanced forest:  
\[d_{n}(y,K|\Omega_{g})=\sigma(f_{n}(y,K|\Omega_{g})) \tag{9}\]  
where \(\sigma(x)=\left(1+e^{-x}\right)^{-1}\) is the sigmoid function, \(K\) is the parametrization of the network, the Adaptive Moment Estimation approach is used to minimize the risk with respect to \(K,\Omega_{g}\) is the age sub-forest with different genders and \(n\) is a decision node. We employed an Information Gain approach to split a node into its left and right child nodes in the tree construction:  
\[\widetilde{\varphi}=\underset{\varphi}{\text{argmax}}(H(d_{n})-\sum_{S\in \left\{N_{e},N_{l}\right\}}\frac{\left|d_{n}^{S}\right|}{\left|d_{n}\right|}H( d_{n})) \tag{10}\]  
where \(\frac{d_{n}^{S}}{d_{n}},S\in\left\{R,L\right\}\) is the probability between the number of feature samples in \(d_{n}^{L}\) (the left child node) and \(d_{n}^{R}\) (the right child node) and \(H(d_{n})\) is the entropy of \(d_{n}\). Step 3. The conditional random-forest-based face age classifier is dynamically constructed according to face gender.