## 2 Materials and Methods
### Implementation of the DNN Model
#### 2.2.3 Implementation of the DNN  
The mapping relationship between the input features \(\mathbf{x}\) and output target \(\mathbf{y}\) can be established by a fully connected DNN [27; 30]. Neurons in the fully connected layer have connections to all neurons of the previous layer,  
\[\mathbf{y}=\sigma(\mathbf{w}\mathbf{x}+\mathbf{b}), \tag{10}\]  
where \(\mathbf{w}\) is the learnable weights, \(\mathbf{b}\) is the additive bias and \(\sigma\) is the nonlinear activation function.  
The loss function \(J\) of the DNN is  
\[J=\frac{1}{N}\sum_{m}\left\|\mathbf{y}-\mathbf{\hat{y}}\right\|_{2}^{2}+\lambda\left\| \mathbf{w}\right\|_{2}, \tag{11}\]  
where \(\mathbf{\hat{y}}\) is the predicted value and \(\lambda\) is the regularization coefficient to prevent the overfitting of the DNN model.  
Figure 5: Schematic of discretized cross sections.  
\begin{table}
\begin{tabular}{l l} \hline \hline
**Input Features** & \multicolumn{2}{l}{**Non-Dimensional Expression**} \\ \hline Position & \(Y_{i}^{*}=\frac{Y_{i}-Y_{b}}{Y_{i-1}-Y_{b}}\) \\ Area & \(A_{i}^{*}=\frac{A_{i}}{A_{i}}\) \\ Hydraulic diameter & \(D_{i}^{*}=\frac{D_{i}}{D_{i}}\) \\ Upstream angle & \(\alpha_{i}^{+}=\frac{D_{i}-D_{i-1}}{L_{i}}\) \\ Downstream angle & \(\alpha_{i}^{-}=\frac{D_{i+1}-D_{i}}{L_{i+1}}\) \\ Shape change rate & \(\Delta S_{i}^{*}=\frac{L_{i}\Delta S_{i}}{L_{i}\Delta S_{i}}\) \\ Pressure drop & \(\Delta P_{i}^{*}=\frac{\Delta P}{\xi(\frac{\Delta P}{\xi})^{2}}\) \\ Re & \(Re_{i}=\frac{\frac{Q_{i}^{*}D_{i}}{v}}{v}\) \\ \hline \hline \end{tabular}
\end{table}
Table 2: Extracted input features.  
The whole data set \((\mathbf{x},\mathbf{y})\) is randomly split into the training and test sets. Since the training set is relatively small, to avoid the overfitting of the model, we use \(k\)-fold cross validation [27] to fine tune the architecture and hyperparameters of the DNN, such as the number of hidden layers, the number of neurons on each hidden layer, the initialization of the weights, the activation function, the optimization method, the mini-batch size, the number of epochs and the dropout rate [27]. By convention, the value of \(k\) is chosen between 5 and 10, therefore the value herein is set to be \(k=5\). The final architecture and hyperparameters of the DNN are chosen from those that have the lowest errors on the validation set. The final DNN model is then trained on the full training set and the prediction performance of the trained model is evaluated on the test set.  
The final architecture of the DNN is illustrated in Figure 6. The input layer has 8 neurons which correspond to the input features in Table 2. To increase the training accuracy and efficiency, the input features have been normalized by the zero-mean normalization [27]. The output layer has a single neuron which corresponds to the ground truth value of the flow resistance coefficient \(f_{r}\). The linear activation function is used on the output layer. Besides the input layer and output layer, there are four hidden layers with 256, 64, 16 and 4 neurons on each of them, respectively. To prevent overfitting, each hidden layer is followed with a dropout layer with a 20% dropout rate [31]. All of the weights on each layer are initialized with a random normal distribution. The Rectified Linear Units (ReLU) activation function [32] is used on the hidden layers. The DNN model is optimized using a mean-squared loss function with an adaptive version of the stochastic gradient descent algorithm called Nadam (Nesterov Adam) [33]. To balance between the robustness of stochastic gradient descent and the efficiency of batch gradient descent, mini-batch gradient descent is used [33]. The DNN model is trained with 20,000 epochs and the mini-batch size is 256 for each epoch. The DNN model is implemented on the open-source machine learning platform Keras [34] using TensorFlow [35] as the backend.