## 2 Theory of the MZI-Based ONN
\[y_{j}=\sum_{i=1}^{i=n}x_{i}w_{i,j}+b_{i,j} \tag{7}\]  
\[\mathbf{Y}=\mathbf{X}\cdot\mathbf{W}+\mathbf{b} \tag{8}\]  
Therefore, we can use same way in a neural network like a back-propagation algorithm to optimize \(\mathbf{H}\) matrix value in the lower loss function value as shown in Equation (9),  
\[\mathbf{H}_{t+1}=\mathbf{H}_{t}-\alpha\cdot\
abla_{\mathbf{H}_{t}}L \tag{9}\]  
where \(\alpha\) is the learning rate, \(\
abla\) is the gradient operator, \(L\) is the loss function value, and \(t\) is the current epoch. Due to the unitary property inherent in linear transformation matrices, the inverse matrix \([\mathbf{S}_{\text{MZI}}]^{-1}\) of each MZI is equal to its conjugate transpose as Equation (10)  
\[S_{\text{MZI}}^{-1}=-je^{-j\left(\frac{\theta}{2}\right)} \begin{bmatrix}e^{- j\varphi}\text{sin}\left(\frac{\theta}{2}\right)&\text{cos}\left(\frac{\theta}{2} \right)\\ e^{-j\varphi}\text{cos}\left(\frac{\theta}{2}\right)&-\text{sin}\left(\frac{ \theta}{2}\right)\end{bmatrix}  \tag{10}\]  
Hence, the decomposition of \(\mathbf{H}\) is equivalent to the reverse arrangement of MZIs. This leads to successive products culminating in the eventual formation of the identity matrix as shown in Equation (11). Through the sequential multiplication of \(\mathbf{H}\) by \([\mathbf{D}_{\mathbf{n}}]^{-1}\) in a defined order, the off-diagonal elements in both the upper and lower triangles of the matrix would eventually become 0. Subsequently, Gaussian elimination can be applied to determine the phase shift values \(\varphi\) and \(\theta\) at each phase shifter. \[\mathbf{H}\cdot[\mathbf{D}_{\mathbf{1}}]^{-1}\cdot[\mathbf{D}_{\mathbf{2}}]^{-1}\cdot[\mathbf{D}_\mathbf{{3}}]^{-1}\cdot[\mathbf{D}_{\mathbf{4}}]^{-1}\cdot[\mathbf{D}_{\mathbf{5}}]^{-1}\cdot[\mathbf{D}_{ \mathbf{6}}]^{-1}= \begin{bmatrix}1&0&0&0\\ 0&1&0&0\\ 0&0&1&0\\ 0&0&0&1\end{bmatrix}  \tag{11}\]  
When the MZI-based ONN has been trained, it can be operated as a PAM4 signal classifier as illustrated in Figure 4. It shows that after the trained MZI-based ONN, different  
Figure 3: The \(4\times 4\) fully connected layer neural network operation. photodiodes (PDs) will be detected corresponding to different levels in the PAM4 input data. However, this part is only the linear operation, and nonlinear activation is needed to handle more complicated scenario. The nonlinear activation function plays a pivotal role in the functionality of a neural network. In the ONN, one way to achieve nonlinear activation is use the structure shown in Figure 5, which is known as the electro-optic nonlinear activation function [24]. As illustrated in Figure 5, the electro-optic nonlinear activation function structure consists of a directional coupler (DC), a PD, an electric amplifier, and a MZI. In the proposed work, the electrical amplifier is implemented off chip. The DC splitter divides the light into two paths. One pathway receives a fraction \(\alpha\) of the input light power, which is then sent to the PD for conversion into an electric signal. In contrast, the remaining fraction of the input light power, which is \(1-\alpha\), is directed to the MZI after an appropriate time delay. The PD output voltage will be amplified by the electric amplifier and combined with a proper voltage \(V_{b}\) to input to the MZI phase shift. The operation of electro-optic nonlinear activation function is illustrated in Equation (12), with the two internal components defined in Equations (13) and (14). \[f(z)=j\sqrt{1-\alpha}e^{-j(\frac{g\varphi|z|^{2}}{2}-\frac{\varphi_{b}}{2})} \cdot\cos\left(\frac{g\varphi|z|^{2}}{2}+\frac{\varphi_{b}}{2}\right)z \tag{12}\]  
\[\varphi_{b}=\pi\frac{V_{b}}{V_{\pi}} \tag{13}\]  
\[g_{\varphi}=\pi\frac{\alpha GR}{V_{\pi}} \tag{14}\]  
Above, \(z\) is the input light field, \(\alpha\) is the DC split power ratio, \(V_{\pi}\) is the voltage of the MZI phase shift \(\pi\), \(G\) is the gain of the electric amplifier, and \(R\) is the responsivity.