## 3 Methodology
### Beauty Pattern Deep Learning and Knowledge Transfer
#### 3.4.1 FBP Based on AlexNet  
The AlexNet [43] is an eight-layer CNN comprising five convolutional layers and three fully connected layers. Figure 2 and Table 3 show the layer configurations of the proposed AlexNet-regression-based for FBP. The ReLU activation function is employed in all layers except for the output layer that uses the Softmax activation function. To accurately estimate the facial attractiveness score, the knowledge of AlexNet was transferred, and its architecture was modified. This involved substituting the regression-loss function for Softmax, which transformed the classification process into a regression task. Moreover, this was due to the fact that the lower layers of a CNN can learn general low-level features, while higher layers capture task-specific features. We proposed reusing the pretrained weights of lower layers and tuning higher ones. This approach saves time, lets the network adapt efficiently, prevents overfitting, and preserves generalization ability; it was applied to freeze the first two convolutional layers and tune the rest of the layers to be adapted for facial aesthetic assessment. \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Setting** \\ \hline Initial learning rate & \(1\times 10^{-4}\) \\ Batch size & 32 \\ MaxEpochs & 150 \\ Optimizer & Adam \\ \hline \hline \end{tabular}
\end{table} 
Table 2: The hyperparameters’ configuration for model training. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Layer Name** & **Kernels** & **Size** & **Stride** \\ \hline Input & \(227\times 227\times 3\) & \\ Convolutional\_1 + BN + ReLU & 96 & \(11\times 11\) & 4 \\ Max pooling\_1 & & \(3\times 3\) & 2 \\ Convolutional\_2 + BN + ReLU & 256 & \(5\times 5\) & 1 \\ Max pooling\_2 & & \(3\times 3\) & 2 \\ Convolutional\_3 + ReLU & 384 & \(3\times 3\) & 1 \\ Convolutional\_4 + ReLU & 384 & \(3\times 3\) & 1 \\ Convolutional\_5 + ReLU & 256 & \(3\times 3\) & 1 \\ Max pooling\_3 & & \(3\times 3\) & 2 \\ Fully Connected fc6 & & & \\ Fully Connected fc7 & & & \\ Fully Connected fc8 & & & \\ The proposed ensemble loss with & & & \\ response & & & \\ Regression & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 3: The configurations of the proposed AlexNet-regression-based for FBP. ```
Input: Training, validation sample sets: (\(X\)train, \(y\)train), and (\(X\)validation, \(y\)validation). Output: Predicted facial beauty score r: \(y\). \(\bullet\) Start. 1. Load the pretrained network: net = pretrainedNetwork;
2. Freeze the required number of layers based on the network's architecture and its initial task design: numFrozenLayers = desiredNumFrozenLayers; for i = 1:numFrozenLayers net.Layers(i).Trainable = false; End. 3. Remove fully connected layers: net = removeLayers(net, {'ClassificationLayer_softmax', 'fc'}). 4. Replace Softmax and classification layer with a regression-loss function: outputLayer = regressionLayer('Name','regressionLayer'). 5. Add a new fully connected layer for beauty score prediction: numOutputNodes = 1; fc = fullyConnectedLayer(numOutputNodes, 'Name', 'fc'). 6. Adjust hyperparameters and training options. 7. Train the model with 5-fold cross-validation (tuning the rest of the unfrozen layers): numFolds = 5; partitionedData = cpartition(numSamples, 'KFold', numFolds); for fold = 1:numFolds trainingIdx = training(partitionedData, fold); trainingDataFold = augmentedData(trainingIdx). \(\circ\) Train the model using different regression-loss functions individually, namely L1 loss, L2 loss, Log-cosh, and the proposed ensemble average loss function:trainedModel = trainNetwork(net, trainingDataFold, layers(fc, outputLayer), options); \(\circ\) Save the trained model and evaluation metrics for this fold. End. 8. Evaluate model performance on testing data: predictions = predict(trainedModel, validationData); pc = calculatePearsonCorrelation(predictions, validationScores); mae = calculateMeanAbsoluteError(predictions, validationScores); mse = calculateMeanSquaredError(predictions, validationScores). 9. Stop.