Skip to content

Tutorials and code collections of my publications associated with photonic neural networks.

License

Notifications You must be signed in to change notification settings

Ydeh22/Photonic-Neural-Networks

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Photonic Neural Networks

The 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 in pnn library, which is now available on pypi. The derivation and tutorials can be found in my blog.

Installation

You can download the pnn package via pip manager. 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 -U tag and update to the latest version.

pip install pnn

Usage

The hierarchy of the project is depicted as follows. Currently pnn comprises two modules: methods and utils.

import pnn

In the utils module, we provide some shortcut functions and classes:

  1. modified trigonometic functions such as atan2f, angle_diff;
  2. built-in transfer functions of photonic devices such as U2BS, U2MZI;
  3. random unitary generator in complex field such as unitary;
  4. fidelity calculation in terms of a pair of matrices such as fidelity;
  5. decomposition methods from numpy and scipy such as svd and cossin.
from pnn.utils import unitary, fidelity, svd

In the methods module, we provide Reck's, Clements' and Yinyi's decomposition methods regarding the matrix mapping of PNN. The functions are wrapped as decompose_<name> and reconstruct_<name>. The details about APIs are listed below:

from pnn.methods import decompose_reck, reconstruct_reck
from pnn.methods import decompose_clements, reconstruct_clements
from pnn.methods import decompose_yinyi, reconstruct_yinyi

# Generate Random Unitary Matrix
u = 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' Method
umi = 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 U
umi = decompose_yinyi(u, block='mzi', depth=0)

# Decompose from the root to the children and the grand children
umi.decompose_recursive(depth=2)

# Decompose from the children matrix to its children individually
umi.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.u1
print(umi.u1.u1.matrix)
print(umi.u1.u2.matrix)
print(umi.u1.v1h.matrix)
print(umi.u1.v2h.matrix)

Citation

Please 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.

About

Tutorials and code collections of my publications associated with photonic neural networks.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Jupyter Notebook 98.6%
  • Python 1.4%