Package: pnn
Photonic Neural NetworksThe aim of this project is to create an easy and light-weight libraries of photonic neural networks (PNNs). The current version only includes the models of universal multiport interferometers. We provide Reck's, Clements' and our presented methods inpnnlibrary, which is now available onpypi. Thederivationandtutorialscan be found in myblog.InstallationYou can download thepnnpackage viapipmanager. Copy the command below and paste it onto your terminal. Note that this project is still under development. Once you installed the outdated package, add-Utag and update to the latest version.pipinstallpnnUsageThe hierarchy of the project is depicted as follows. Currentlypnncomprises two modules:methodsandutils.importpnnIn theutilsmodule, we provide some shortcut functions and classes:modified trigonometic functions such asatan2f,angle_diff;built-in transfer functions of photonic devices such asU2BS,U2MZI;random unitary generator in complex field such asunitary;fidelity calculation in terms of a pair of matrices such asfidelity;decomposition methods fromnumpyandscipysuch assvdandcossin.frompnn.utilsimportunitary,fidelity,svdIn themethodsmodule, we provide Reck's, Clements' and Yinyi's decomposition methods regarding the matrix mapping of PNN. The functions are wrapped asdecompose_<name>andreconstruct_<name>. The details about APIs are listed below:frompnn.methodsimportdecompose_reck,reconstruct_reckfrompnn.methodsimportdecompose_clements,reconstruct_clementsfrompnn.methodsimportdecompose_yinyi,reconstruct_yinyi# Generate Random Unitary Matrixu=pnn.utils.unitary(dim=100)# Decompose by Reck' Method[phi,theta,alpha]=decompose_reck(u,block='mzi')Ue=reconstruct_reck(phi,theta,alpha,block='mzi',Lp_dB=0.03,Lc_dB=0.1)f_clements=fidelity(u,Ue)# Decompose by Clements' Method[phi,theta,alpha]=decompose_clements(u,block='mzi')Ue=reconstruct_clements(phi,theta,alpha,block='mzi',Lp_dB=0.03,Lc_dB=0.1)f_clements=fidelity(u,Ue)# Decompose by Yinyi' Methodumi=decompose_yinyi(u,block='mzi',depth=8)Ue=reconstruct_yinyi(umi,block='mzi',Lp_dB=0.03,Lc_dB=0.1)f_clements=fidelity(u,Ue)Since Yinyi's is an argumented method over Reck's and Clements' to enable spatial arrangement along the new axis (the direction of plane normal), it supports some distinctive features and APIs:# Decompose large unitary matrix Uumi=decompose_yinyi(u,block='mzi',depth=0)# Decompose from the root to the children and the grand childrenumi.decompose_recursive(depth=2)# Decompose from the children matrix to its children individuallyumi.u1=decompose_yinyi(umi.u1,block='bs',depth=1)umi.u2=decompose_yinyi(umi.u2,block='mzi',depth=2)umi.v1h=decompose_yinyi(umi.v1h,block='bs',depth=3)umi.v2h=decompose_yinyi(umi.v2h,block='mzi',depth=4)# Obtain and print the children matrix values of umi.u1print(umi.u1.u1.matrix)print(umi.u1.u2.matrix)print(umi.u1.v1h.matrix)print(umi.u1.v2h.matrix)CitationPlease cite the corresponding papers if you find this work useful:Yinyi Liu et al."A Reliability Concern on Photonic Neural Networks."Design, Automation and Test in Europe Conference (DATE). 2022.Yinyi Liu et al."Reduce the Footprints of Multiport Interferometers by Cosine-Sine Decomposition."Optical Fiber Communication (OFC). 2022.