# Quantifying Quantum Coherence Using Machine Learning Methods
## 3 Results  
Now, let us train the model for \(\rho\) for the two-qubit systems. The numbers of nodes in the three hidden layers are all set to 64 and the number of trainable parameters for this network is 9473. The loss functions (MSE) are plotted against epoch for both the training set and validation set in Figure 2. It can be shown in Figure 2 that both errors decrease dramatically in the first few epochs. As we continue the training, the MSE for the training set keeps decreasing, while the MSE for the validation set has some ups and downs. This indicates the possibility of overfitting. Now, we use the early stopping strategy that in case the loss function does not improve over 10 epochs, the training stops. Eventually, the training process finishes at an epoch of about 38. In order to see the generalization ability of the trained model, we apply it to the test set. The MSE for the test set is \(2.3644\times 10^{-4}\). These error values are small and imply the  
Figure 2: The loss functions (MSE) are plotted against epoch for both training set (dashed line) and validation set (solid line) with \(d=4\). Early stopping strategy has been used. trained network has a good generalization on the test set. In order to see this more clearly, we plot the predicted ROC versus the actual ROC for the test set in Figure 3. The horizontal and vertical coordinates of each hollow circle in the figure represent the actual values and predicted values of ROC, respectively, by the trained model for one sample in the test set. The red line indicates the case that the predicted ROC equals the actual ROC. The closer these dots are to the line, the more accurate the predicted ROC is. Moreover, we also calculate the \(R^{2}=0.9994\), which is high and close to 1. We can see that the trained model has a strong generalization ability on the test set. As an application, we now apply the trained model to the coherence dynamics for a two-qubit system under a non-Markovian environment. This system is composed of two parts, each one consisting of a two-level system interacting with a reservoir [51]. The Hamiltonian of the system is  
\[H=\hbar\omega_{0}\sigma_{+}\sigma_{-}+\sum_{k}\left[\hbar\omega_{k}b_{k}^{ \dagger}b_{k}+\left(g_{k}\sigma_{+}b_{k}+g_{k}^{*}\sigma_{-}b_{k}^{\dagger} \right)\right], \tag{6}\]  
where \(\omega_{0}\) is the transition frequency, \(\sigma_{\pm}\) is the system raising and lowering operators for the qubit, \(b_{k}^{\dagger}\) (\(b_{k}\)) is the creation (annihilation) operator, and \(g_{k}\) is the coupling of the mode \(k\) with frequency \(\omega_{k}\). If the initial state is the Werner-like state  
\[\rho=r|\Phi\rangle\langle\Phi|+\frac{1-r}{4}I \tag{7}\]  
with \(r\) the purity and the coupling are non-Markovian with spectral density  
\[J(\omega)=\frac{1}{2\pi}\frac{\Gamma\lambda^{2}}{(\omega_{0}-\omega)^{2}+ \lambda^{2}}, \tag{8}\]  
where \(\Gamma\) is the system-reservoir coupling constant and \(\lambda\) is the spectral width of the coupling. We obtain the density matrix of the qubits system according to Ref. [51] and calculate the ROC using both the SDP method and the FNN. In Figure 4, we plot the predicted and the actual ROC as a function of the dimensionless quantity \(\Gamma t\). It can be seen that our trained model has a good generalization. Moreover, it is worth noting that the time required to process a single state using the FNN is approximately \(10^{-6}\) s, whereas using the SDP method directly takes around \(10^{-1}\) s. This means our method is roughly \(10^{5}\) times faster than the SDP approach. Figure 3: The predicted ROC versus the actual ROC for 4-dimensional space test set are marked with blue circles. The red line indicates the case that the predicted ROC equals to the actual ROC. Next, we discuss larger dimension states of the qubit-qutrit and the three-qubit systems. The Hilbert space dimensions of these two systems are 6 and 8, respectively. In these cases, the performance decreases when using the same structure of neural network model as in previous two-qubit system.