# Zernike Coefficient Prediction Technique for Interference Based on Generation Adversarial Network
## 2 Methods  
### Datasets for GAN Model  
We need two input images, for the Generator and the Discriminator networks, to train the GAN model. First, we generate images as the input of the Generator network based on the optics formula in Python since the interferometer cannot easily obtain many actual pictures in a short time. We need to sequentially generate the phase difference and the interference fringe based on two formulas. The phase difference formula is represented by Zernike polynomials based on a polar coordinate system, as shown in Equation (1). \[\delta(r,\theta)=\sum_{n=1}^{N}a_{n}z_{n}(r,\theta) \tag{1}\]  
where the \(\delta\) represents the appearance of the phase difference, \(a_{n}\) represents the value of the nth Zernike coefficients, and \(z_{n}\) represents the nth item in the polynomials. In this paper, the range of \(a_{n}\) is \(-0.5\)-\(0.5\), radius \(r\) is \(0\)-\(1\), angle \(\theta\) is \(0\)-\(2\pi\), and order \(n\) is \(1\)-\(32\). When producing the datasets, the Zernike coefficients are set randomly. The piston term in the first order of the Zernike mode should be ignored because it does not affect the wavefront distribution. Additionally, we do not analyze the piston term. Moreover, each Zernike polynomials item represents a kind of aberration meaning and the coefficient is a quantitative aberration. Then, we use the phase difference to calculate the interference fringe based on the interference fringe formula, as shown in Equation (2), where \(I_{a}\) is the reference light and \(I_{b}\) is the tested light. Since the interference fringe formula is a series of the cosine function, the positive and negative values of Zernike coefficients may have a chance to produce the same interference fringes. Therefore, these datasets should not be used for model training because one input fringe image corresponds to more than one series of coefficients. To solve this problem, we use the phase shift method to make the GAN model distinguish between positive and negative values of Zernike coefficients. \[\rm{I}=\rm{I_{a}}+\rm{I_{b}}+2\sqrt{\rm{I_{a}}\rm{I_{b}}}\cos(\delta) \tag{2}\]  
According to the phase-shift method, we use two interference fringes, including the original interference fringe and the reference fringe based on the phase difference adding \(\rm{\pi/4}\), as shown in Equations (3) and (4). Regarding how to combine the two images for the model's input, a previous paper divided the two interference fringes for generating one input image [25]. However, during the training process, there is a phenomenon of divergence or overfitting when we only divided the two fringes. Therefore, this paper further uses the logarithmic divided fringes in our training experience, as shown in Equation (5). The possible reason is that some of the I' values are too large when the I2 values are too small or close to zero. Therefore, the input interference fringe images are adjusted in this paper, and the training dataset is different from the previous article [25]. The image size is 256 \(\times\) 256 pixels. \[\rm{I_{1}}=\rm{I_{a}}+\rm{I_{b}}+2\sqrt{\rm{I_{a}}\rm{I_{b}}}\cos(\delta) \tag{3}\]  
\[\rm{I_{2}}=\rm{I_{a}}+\rm{I_{b}}+2\sqrt{\rm{I_{a}}\rm{I_{b}}}\cos\left(\delta +\frac{\rm{\pi}}{4}\right) \tag{4}\]  
\[\rm{I^{\prime}}=\rm{log}\left(\frac{\rm{I_{1}}}{\rm{I_{2}}}\right) \tag{5}\]  
Second, we also generate the ground truth, with Zernike coefficients as one of the Discriminator's inputs; another input is a fake image that is the output of the Generator network. The actual image is designed with 32 equal pieces, and each part corresponds to one of the Zernike coefficients. The image size is 256 \(\times\) 256 pixels, so each piece has 2048 pixels. An example of the target image looks similar to a mosaic image, and the size of each piece is 32 \(\times\) 64 pixels, as shown in Figure 1a, where c1 is the first Zernike coefficient and c2 is the second Zernike coefficient, etc. Therefore, the GAN becomes the image-to-number translation network.