A coherent perceptron for all-optical learning

We present nonlinear photonic circuit models for constructing programmable linear transformations and use these to realize a coherent perceptron, i.e., an all-optical linear classifier capable of learning the classification boundary iteratively from training data through a coherent feedback rule. Through extensive semi-classical stochastic simulations we demonstrate that the device nearly attains the theoretical error bound for a model classification problem.


Introduction
Recent progress in integrated nanophotonic engineering [23,12,27,38,14,18,35,8,52,41] has motivated follow-up proposals [28,36] of nanophotonic circuits for all-optical information processing.While most of these focus on implementations of digital logic, we present here an approach to all-optical analog, neuromorphic computation and propose design schemes for a set of devices to be used as building blocks for large scale circuits.
Optical computation has been a long-time goal [1,43], with research interest surging regularly after new engineering capabilities are attained [32,33], but so far the parallel progress and momentum of CMOS based integrated electronics has outperformed all-optical devices.
In recent years we have seen rapid progress in the domain of machine learning, and artificial intelligence in general.Although most current 'big data'-applications are realized on digital computing architectures, there is now an increasing amount of computation done in specialized hardware such as GPUs.Specialized analog computational devices for solving specific subproblems more efficiently than possible with either GPUs or general purpose computers are being considered or already implemented by companies such as IBM, Google and HP and in academia, as well.[2,34,44,54] Specifically in the field of neuromorphic computation, there has been impressive progress on CMOS based analog computation platforms [7,6].
Several neuromorphic approaches to use complex nonlinear optical systems for machine learning applications have recently been proposed [13,51,50,11] and some initial schemes have been implemented [24,52].So far, however, all of these 'optical reservoir computers' have still required digital computers to prepare the inputs and process the output of these devices with the optical systems only being employed as static nonlinear mappings for dimensional lifting to a high dimensional feature space [10], in which one then applies straightforward linear regression or classification for learning an input-output map.[53] In this work, we address how the final stage of such a system, i.e., the linear classifier could be realized all-optically.We provide a universal scheme, i.e., independent of which particular kind of optical nonlinearity is employed, for constructing tunable all-optical, phase-sensitive amplifiers and then outline how these can be combined with self-oscillating systems to realize an optical amplifier with programmable gain, i.e., where the gain can be set once and is then fixed subsequently.
Using these as building blocks we construct an all-optical perceptron [39,40], a system that can classify multi-dimensional input data and, using pre-classified training data learn the correct classification boundary 'on-line', i.e., incrementally.The perceptron can be seen as a highly simplified model of a neuron.While the idea of all-optical neural networks has been proposed before [31] and an impressive scheme using electronic, measurement-based feedback for spiking optical signals has been realized [16], to our knowledge, we offer the first complete description for how the synaptic weights can be stored in an optical memory and programmed via feedback.
The physical models underlying the employed circuit components are high intrinsic-Q optical resonators with strong optical nonlinearities.For theoretical simplicity we assume resonators with either a χ 2 or a χ 3 nonlinearity, but the design can be adapted to depend on only one of these two or alternative nonlinearities such as those based on free carrier effects or optomechanical interactions.
The strength of the optical nonlinearity and the achievable Q-factors of the optical resonators determine the overall power scale and rate at which a real physical device could operate.Both a stronger nonlinearity and higher Q allow operating at lower overall power.
We present numerical simulations of the system dynamics based on the semi-classical Wigner-approximation to the full coherent quantum dynamics presented in [41].For photon numbers as low as (∼ 10 − 20) this approximation allows us to accurately model the effect of optical quantum shot noise even in large-scale circuits.
In the limit of both very high Q and very strong nonlinearity, we expect quantum effects to become significant as entanglement can arise between the field modes of physically separated resonators.In the appendix, we provide full quantum models for all basic components of our circuit.The possibility of a quantum speedup is being addressed in ongoing work.Recently, D-Wave Systems has generated a lot of interest in their own superconducting qubit based quantum annealer.Although the exact benefits of quantum dynamics in their machines has not been conclusively established [4], recent results analyzing the role of tunneling in a quantum annealer [5] are intriguing and suggest that quantum effects can be harnessed in computational devices that are not unitary quantum computers.

The Perceptron algorithm
The perceptron is a machine learning algorithm that maps an input x ∈ R n to a single binary class label ŷw [x] ∈ {0, 1}.Binary classifiers generally operate by dividing the input space into two disjoint sets and identifying these with the class labels.The perceptron is a linear classifier, meaning that the surface separating the two class label sets is a linear space, a hyperplane, and its output is computed simply by applying a step function θ(u) := 1 u≥0 to the inner product of a single data point x with a fixed weight vector w: Geometrically, the weight vector w parametrizes the hyperplane {z ∈ R n : w T z = 0} that forms the decision boundary.
In the above parametrization the decision boundary always contains the origin z = 0, but the more general case of an affine decision boundary {z ∈ R n : wT z = b} can be obtained by extending the input vector by a constant z = (z T , 1) T ∈ R n+1 and similarly defining an extended weight vector w = ( wT , −b) T .
The perceptron converges in a finite number of steps for all linearly separable problems [39] by randomly iterating over a set of pre-classified training data {(y (j) , x (j) ) ∈ {0, 1} ⊗ R n , j = 1, 2, . . ., M } and imparting a small weight correction w → w + ∆w for each falsely classified training example x (j) ∆w = α y (j) − ŷw [x (j) ] x (j) . ( The learning rate α > 0 determines the magnitude of the correction applied for each training example.The expression in parentheses can only take on the values {0, −1, 1} with the zero corresponding to a correctly classified example and the non-zero values corresponding to the two different possible classification errors.Usually there exist many separating hyperplanes for a given linear binary classification problem.The standard perceptron is only guaranteed to find one that works for the training set.It is possible to introduce a notion of optimality to this problem by considering the minimal distance ("margin") of the training data to the found separating hyperplane.Maximization of this margin naturally leads to the "support vector machine" (SVM) algorithm [9].Although the SVM outperforms the perceptron in many classification tasks it does not lend itself to a hardware implementation as readily because it cannot be trained incrementally.It is this that makes the perceptron algorithm especially suited for a hardware implementation: We can convert the discrete update rule (2) to a differential equation and then construct a physical system that realizes these dynamics.In this continuous-time version the inputs are piece-wise constant x(t) = x (jt) , y(t) = y (jt) and take on the same discrete values as above indexed by j t := t ∆t ∈ {1, 2, . . ., M = T ∆t }.

The circuit modeling framework
Circuits are fully described via Quantum Hardware Description Language (QHDL) [49] based on Gough and James' SLH-framework [20,19].To carry out numerical simulations for large scale networks, we derive a system of semi-classical Langevin equations based on the Wigner-transformation as described in [41].Note that there is a perfect one-to-one correspondence between nonlinear cavity models expressed via SLH and the Wigner method as long as the nonlinearities involve only oscillator degrees of freedom.There is ongoing research in our group to establish similar results for more general nonlinearities [22].
Both the Wigner method and the more general SLH framework can be used to model networks of quantum systems where the interconnections are realized through bosonic quantum fields.The SLH framework describes a system interacting with n independent input fields in terms of a unitary scattering matrix S parametrizing direct field scattering, a coupling vector L = (L 1 , L 2 , . . ., L n ) T parametrizing how external fields couple into the system and how the system variables couple to the output and a Hamilton operator inducing the internal dynamics.We summarize these objects in a triplet (S, L, H).L and H are sufficient to parametrize any Schrödinger picture simulation of the quantum dynamics, e.g., the master equation for a mixed system state ρ is given by The scattering matrix S is important when composing components into a network.In particular, the input-output relation in the SLH framework is given by where the dA in/out,j , j = 1, 2, . . ., n are to be understood as quantum stochastic processes whose differentials can be manipulated via a quantum Ito calculus [20].The Wigner method provides a simplified, approximate description which is valid when all non-linear resonator modes are in strongly displaced states [41].The simulations presented here were carried out exclusively at energy scales for which the Wigner method is valid, allowing us to scale to much larger system sizes than we could in a full SLH-based quantum simulation.This is because the computational complexity of the Wigner method scales at most quadratically (and in sparsely interconnected systems nearly linearly) with the number of components as opposed to the exponential state space scaling of a quantum mechanical Hilbert space.We nonetheless provide our models in both Wigner-method form and SLH form in anticipation that our component models will also be extremely useful in the full quantum regime.
In the Wigner-based formalism, a system is described in terms of time-dependent complex coherent amplitudes α(t) = (α 1 (t), α 2 (t), . . ., α m (t)) T for the internal cavity modes and external inputs β in (t) = (β in,1 (t), β in,2 (t), . . ., β in,n (t)) T .These amplitudes relate to quantum mechanical expectations as α j ≈ a j QM , where • denotes the expectation with respect to the Wigner quasi distribution and • QM a quantum mechanical expectation value.See [41] for the corresponding relations of higher order moments.
To simplify the analysis, we exclusively work in a rotating frame with respect to all driving fields.As in the SLH case we define output modes β out (t) that are algebraically related to the inputs and the internal modes.The full dynamics of the internal and external modes are then governed by a multi-dimensional Langevin equation as well as a purely algebraic, linear input-output relationship The complex matrices A, B, C, D as well as the constant bias input vectors a and c parametrize the linear dynamics, whereas the function A NL (α, t) gives the nonlinear contribution to the dynamics of the internal cavity modes.
The linearity of the input-output relationship in either framework ( 5) and (7) in the external degrees of freedom leads to algebraic rules for deriving reduced models for whole circuits of nonlinear optical resonators by concatenating component models and algebraically solving for their interconnections.[19,41] To see the basic component models used in this work see Appendix A. Netlists for composite components and the whole circuit will be made available at [47].

The Coherent Perceptron Circuit
The full perceptron's circuit is visualized in Figure 1.The input data x to the perceptron + Quadrature Filter Thresholder Figure 1: An example perceptron circuit consisting of N = 4 programmable amplifiers for the coherent input vector x = (x 1 , x 2 , x 3 , x 4 ) T , a static mixing element that sums their output, a quadrature filter to remove the imaginary quadrature and a final thresholding element to generate the estimated binary class label ŷ.The additional binary input T controls whether the system is in training mode, in which case the estimated class label ŷ is compared to the true class label Y which is provided as an additional input.When they differ, the programmable amplifiers receive a feedback signal to adjust their internal weights.
circuit is encoded in the real quadrature of N coherent optical inputs.Equation (3) informs us what circuit elements are required for a hardware implementation by decomposing the necessary operations: 1.Each input x j is multiplied by a weight w j .
2. The weighted inputs are coherently added.
3. The sum drives a thresholding element to generate the estimated class label ŷ.
4. In the training phase (input T = 1) the estimated class label ŷ is compared with the true class label (input Y ) and based on the outcome, feedback is applied to modify the weights {w j }.
The most crucial element for this circuit is the system that multiplies an input x j with a programmable weight w j .This not only requires having a linear amplifier with tunable gain, but also a way to encode and store the continuous weights w j .In the following we outline one way how such systems can be constructed from basic nonlinear optical cavity models: Section 2.1 presents an elegant way to construct a phase sensitive linear optical amplifier where the gain can be tuned by changing the amplitude of a bias input.In Section 2.2 we propose using an above threshold non-degenerate optical parametric amplifier to store a continuous variable in the output phase of the signal (or idler) mode.In Section 2.3 these systems are combined to realize an optical amplifier with programmable gain, i.e., a control input can program its gain, which then stays constant even after the control has been turned off.Finally, we present a simple model for all-optical switches based on a cavity with two modes that interact via a cross-Kerr-effect in Section 2.4.This element is used both for the feedback logic as well as the thresholding function to generate the class label ŷ.

Tunable Gain Kerr-amplifier
A single mode Kerr-nonlinear resonator driven by an appropriately detuned coherent drive can have a strongly nonlinear dependence of the intra-cavity energy on the drive power.When the drive of a single resonator is given by the sum of a constant large bias amplitude and a small signal =1 √ 2 ( 0 + δ ), the steady state reflected amplitude is = 1 , where |η| ≤ 1 with equality for the ideal case of negligible intrinsic cavity losses.The small signal thus experiences phase sensitive gain dependent on the bias amplitude and phase.We provide analytic expressions for the gain in Appendix A.2.1.
Placing two identical resonators in the arms of an interferometer allows for isolating the signal and bias outputs even if their amplitudes vary by canceling the scattered bias in one output and the scattered signal in the other (cf. Figure 2).This highly symmetric construction, which generalizes to any other optical nonlinearity, ensures that the the signal output is linear in δ up to third order 1 .If the system parameters are well-chosen, the amplifier gain depends very strongly on small variations of the bias amplitude.This allows to tune the gain from close to unity to its maximum value, which, for a given waveguide coupling κ and Kerr coefficient χ depends on the drive detuning from cavity.For Kerrnonlinear resonators there exists a critical detuning beyond which the system becomes bi-stable and exhibits hysteresis.This can be used for thresholding type behavior though as shown in [46] in this case it may be advantageous to reduce the symmetry of the circuit.It is convenient to engineer the relative propagation phases such that at maximum gain, a real quadrature input signal x ∈ R leads to an amplified output signal x = g max rr x with no imaginary quadrature component (other than noise and higher order contributions).However, for different bias input amplitudes and consequently lower gain values the output will generally feature a linear imaginary quadrature component x = [g rr ( 0 ) + ig ir ( 0 )] x as gives the phase sensitive amplifier gain g rr ( 0 ) (green, solid) and the g ir ( 0 ) (red, dashed) as a function of the bias photon input rate normalized by the drive power at which dynamic resonance occurs.For completeness we also provide g ri (black X's) and g ii (black dots).The detuning has been chosen such that g max rr = g rr ( max 0 ) = 20.The dashed blue envelope gives the maximal input output gain achievable between any two signal quadratures at that bias.Note that g rr vanishes at well. Figure 2(b) demonstrates this for a particular choice of maximal gain.We note that there exist previous proposals of using nonlinear resonator pairs inside interferometers to achieve desirable input-output behavior [46], but to our knowledge, no one has proposed using these for signal/bias isolation and tunable gain.To first order the linearized Kerr model is actually identical to a sub-threshold degenerate OPO model.This implies that it can be used to generate squeezed light and also that one could replace the Kerr-model by an OPO model.
An almost identical circuit, but featuring resonators with additional internal loss equal to the wave-guide coupling2 and constantly biased to dynamic resonance |α| 2 ss = −∆/χ can be used to realize a quadrature filter, i.e., an element that has unity gain for the real quadrature and zero for the imaginary one.Now the quadrature filtered signal still has an imaginary component, but to linear order this only consists of transmitted noise from the additional internal loss.While it would be possible to add one of these downstream of every tunable Kerr amplifier, in our specific application it is more efficient to add just a single one downstream of where the individual amplifier outputs are summed (cf.Section 2.5).This also reduces the total amount of additional noise introduced to the system.

Encoding and Storing the Gain
In the preceding section we have seen how to realize a tunable gain amplifier, but for programming and storing this gain (or equivalently its bias amplitude) an additional component is needed.Although it is straightforward to design a multi-stable system capable of outputting a discrete set of different output powers to be used as the amplifier bias, such schemes would likely require multiple nonlinear resonators and it would be more cumbersome to drive transitions between the output states.
An alternative to such schemes is given by systems that have a continuous set of stable states.Recent analysis of continuous time recurrent neural network models trained for complex temporal information processing tasks has revealed multi-dimensional stable attractors in the internal network dynamics that are used to store information over time.[45] A simple semi-classical nonlinear resonator model to exhibit this is given by a nondegenerate optical parametric oscillator (NOPO) pumped above threshold; for low pump input powers this system allows for parametric amplification of a weak coherent signal (or idler) input.In this case vacuum inputs for the signal and idler lead to outputs with zero expected photon number.Above a critical threshold pump power, however, the system down-converts pump photons into pairs of signal and idler photons.
Due to an internal U (1) symmetry of the underlying Hamiltonian (cf.Appendix A.2.3), the signal and idler modes spontaneously select phases that are dependent on each other but independent of the pump phase.This implies that there exists a whole manifold of fix-points related to each other via the symmetry transformation (α s , α i ) → (α s e iφ , α i e −iφ ), where α s and α i are the rotating frame signal and idler mode amplitudes, respectively.Consequently the signal output of an above threshold NOPO lives on a circular manifold (cf Figure 3).Vacuum input shot noise leads to small fluctuations perpendicular to the manifold and diffusion along it.Mixing this signal output with a constant bias offset on a beamsplitter produces two outputs with anti-correlated total amplitude (a, lower figure).When both outputs are used to drive a complementary pair of tunable amplifiers whose outputs are subtracted, the overall real-to-real quadrature gain (green) of the system varies from positive to negative values (b).We can also see that the real-to-imaginary gain (dashed red) stays small for all NOPO phases, which allows us to efficiently subtract it downstream by the quadrature filter.The imaginary to real and imaginary gains are also plotted.
Vacuum shot noise on the inputs leads to phase diffusion with a rate of γ Φ = κ 8n 0 , where κ is the signal and idler line width and n 0 is the steady state intra cavity photon number in either mode.We point out that this diffusion rate does not directly depend on the strength of the nonlinearity which only determines how strongly the system must be pumped to achieve a given intra cavity photon number n 0 .
A weak external signal input breaks the symmetry and biases the signal output phase towards the external signal's phase.This allows for changing the programmed phase value.
Finally, we note that parametric oscillators can also be realized in materials with vanishing χ 2 nonlinearity.They have been successfully realized via four-wave mixing (i.e., exploiting a χ 3 nonlinearity) in [23,42,12] and even in opto-mechanical systems [8] in which case the idler mode is given by a mechanical degree of freedom.
In principle any nonlinear optical system that has a stable limit cycle could be used to store and encode a continuous value in its oscillation phase.Non-degenerate parametric oscillators stand out because of their theoretical simplicity allowing for a 'static' analysis inside a rotating frame.

Programmable Gain Amplifier
Combining the circuits described in the preceding sections allows us to construct a fully programmable phase sensitive amplifier.In Figure 2(b) we see that there exists a particular bias amplitude at which the real to real quadrature gain vanishes g rr ( min 0 ) = 0. We combine the NOPO signal output ξ = re iΦ with a constant phase bias input ξ 0 (cf. Figure 3(a)) on a beamsplitter such that the outputs vary between zero gain and the maximal gain bias ].To realize both positive and negative gain, we use the second output of that beamsplitter to bias another tunable amplifier.The two amplifiers are always biased oppositely meaning that one will have maximal gain when the other's gain vanishes and vice versa.The overall input signal is split and sent through both amplifiers and then re-combined with a relative π phase shift.This complementary setup leads to an overall effective gain tunable within In Figure 4 we present both the complementary pair of amplifiers and the NOPO used for storing the bias as well as some logic elements (described in Section 2.4) used for implementing conditional training feedback.We call the full circuit a synapse because it features programmable gain and implements the perceptron's conditional weight update rule.The resulting synapse model is quite complex and certainly not optimized for a minimal component number but rather the ease of theoretical analysis.A more resource efficient programmable amplifier could easily be implemented using just two or three nonlinear resonators.E.g., inspecting the the real to imaginary quadrature gain g ir ( 0 ) in Figure 2(b) we see that close to max 0 it passes through zero fairly linearly and with an almost symmetric range.This indicates that we could use a single tunable amplifier to realize both positive and negative gain.Using only a single resonator for the tunable amplifier could work as well, but it would require careful interferometric bias cancellation and more tedious upfront analysis.We do not think it is feasible to use just a single resonator for both the parametric oscillator and the amplifier because any amplified input signal would have an undesirable back-action on the oscillator phase.

Optical Switches
The feedback to the perceptron weights (cf.Equation ( 3)) is conditional on the binary values of the given and estimated class labels y and ŷ, respectively.The logic necessary for implementing this can be realized by means of all-optical switches.There have been various proposals and demonstrations [37,35] of all-optical gates/switches and quantum optical switches [30].Thresholder input s = 2c−s 0 a.u.The model that we assume here (cf. Figure 5) is to use two different modes of a resonator that interact via a cross-Kerr-effect, i.e., power in the control mode leads to a refractive index shift (or detuning) for the signal mode.The index shift translates to a control mode dependent phase shift of a scattered signal field yielding a controlled optical phase modulator.Wrapping this phase modulator in a Mach-Zehnder interferometer then realizes a controlled switch: If the control mode input is in one of two different states |ξ| ∈ 0, ξ 0 , the signal inputs are either passed through or switched.This operation is often referred to as a controlled swap or Fredkin gate [17] which was originally proposed for realizing reversible computation.This dispersive model has the advantage that the control input signal can be reused.
Note that at control input amplitudes significantly different from the two control levels the outputs are coherent mixtures of the inputs, i.e., the switch then realizes a tunable beamsplitter.
Finally, we point out that using two different (frequency non-degenerate) resonator modes has the advantage that the interaction between control and signal inputs is phase insensitive which greatly simplifies the design and analysis of cascaded networks of such switches.

Generation of the Estimated Label
The estimated classifier label ŷ should be a step function applied to the inner product of the weight vector and the input.In the preceding sections we have shown how individual inputs x j can be amplified with programmable gain to give sj = G(Φ j )x j , thus realizing the individual contributions to the inner product.These are then summed on an n-port beamsplitter that has an output which gives the uniformly weighted sum s := 1 generally have an unwanted imaginary part which we subtract by passing the summed output through a quadrature filter circuit (cf. the last paragraph of Section 2.1), which has unit gain for the real quadrature and zero gain for the imaginary quadrature leading to an overall output s = Re s = 1 The thresholding circuit should now produce a high output if s > 0 and a zero output if s ≤ 0.
It turns out that the optical Fredkin gate described in the previous section already works almost as a two mode thresholder, where the control input leads to a step-like response in the signal outputs: A constant signal input amplitude which encodes the logical '1' state is applied to one of the signal inputs.When the control input amplitude is varied from zero to ξ 0 , the signal output turns on fairly abruptly at some threshold ξ th < ξ 0 .To make the thresholding phase sensitive, the control input is given by the sum of s and a constant offset s 0 that provides a phase reference: c = 1 √ 2 (s + s 0 ).For a Fredkin gate operated with continuous control inputs the signal output is almost zero for a considerable range of small control inputs.However, for very high control inputs, i.e., significantly above ξ 0 , the signal output decreases instead of staying constant as would be desirable for a step-function like profile.We found that this issue can be addressed by transmitting the control input through a single mode Kerr-nonlinear cavity, with resonance frequency chosen such that the transmission gain |c /c| is peaked close to c = ξ 0 .For input amplitudes larger than c, the transmission gain is lower (although |c | still grows monotonically with |c|) which extends the input range over which the subsequent Fredkin gate stays in the on-state.

Results
The perceptron's SDEs where simulated using a newly developed custom software package named QHDLJ [48] implemented in Julia [3] which allows allows for dynamic compilation of circuit models to LLVM [25] bytecode that runs at speed comparable to C/C++.All individual simulations can be carried out on a laptop, but the results in Figure 8 were obtained by averaging over the results of 100 stochastic simulation run on an HP ProLiant server with 80 cores.The current version of QHDLJ uses one process per trajectory, but the code could easily be vectorized.
In Figure 6 we present an example of a single application of an N = 8 perceptron including both a learning stage with pre-labeled training data and a classification testing stage in which the perceptron's estimated class labels are compared with their correct values.The data to be classified here are sampled from a different 8− dimensional Gaussian distribution for each class label with their mean vectors separated by a distance µ 1 − µ 0 2 /σ = 2 relative to the standard deviation of both individual clusters.For each sample the input was held constant for a duration ∆t = 2κ −1 where κ is the NOPO signal and idler line width.The perceptron was first trained with M train = 100 training examples and subsequently tested on M test = 100 test examples with the learning feedback turned off.
In Figure 7 we visualize linear projections of the testing data as well as the estimated classification boundaries.We can see that the classifier performs very well far away from the decision boundary.Close to the decision boundary there are some misclassified examples.We proceed to compare the performance of the classifier to the theoretically optimal performance achievable by any classifier and with the optimal classifier for this scenario, Gaussian Discriminant Analysis (GDA) [15,29], implemented in software.Using the identical perceptron model as above and an identical training/testing procedure, we estimate the error rate p err = P[y = ŷ] of the trained perceptron as a function of the cluster separation µ 1 − µ 0 2 /σ.The results are presented in Figure 8(a).Identically distributed training and testing data was used to evaluate the performance of the GDA algorithm and both results are compared to the theoretically optimal error rate for this discrimination task, which can be computed analytically to be p err, optim.
, where x e −u 2 du is the complementary error function.We see that the all-optical perceptron's performance is comparable to GDA's performance for this problem and both algorithms attain performance close to the theoretical optimum.
The learning rate of the perceptron is determined by two things, the overall strength of the learning feedback as well as the time for which each example is presented to the circuit.In Figure 8(b) we plot the estimated error rate for varying feedback strength and duration.As can be expected intuitively, we find that there are trade-offs between speed (smaller ∆t preferable) and energy consumption (smaller α preferable).

Time scales and power budget
Here we roughly estimate the power consumption of the whole device and discuss how to scale it up to a higher input dimension.
Any real-world implementation will depend strongly on the engineering paradigm, i.e., the choice of material/nonlinearity as well as the engineering precision, but based on recently achieved progress in nonlinear optics we will estimate an order of magnitude range for the input power.
The signal and feedback input power to the circuit will scale linearly in the number of synapses N .
The bias inputs for the amplifiers has to be larger than the signal to ensure linearly operation, but it should be expected that some of the scattered bias amplitudes can be reused to power multiple synapses.In our models we have defined all rates relative to the line width of the signal and idler mode of the NOPO, because this is the component that should necessarily have the smallest decay rate to ensure a long lifetime for the memory.
All other resonators are employed as nonlinear input-output transformation devices and therefore a high bandwidth (corresponding to much lower loaded quality factor) is necessary for achieving a high bit rate.For our simulations we typically assumed quality factors that were lower than the NOPO's by 1-2 orders of magnitude.
Based on self-oscillation threshold powers reported in [23,12,26,38] and the switching powers of [35] we estimate the necessary power per synapse to be in the range of ∼ 10 − 100µWatt.By re-using the scattered pump and bias fields it should be possible to reduce the power consumption per amplifier even further.Even for the continuous wave signal paradigm we have assumed (as opposed to pulsed/spiking signals such as considered in [50]) the devices proposed here could be competitive with the current state of the art CMOS-based neuromorphic electrical circuits [6].
In the simulations for the 8−dimensional perceptron our input rate for training data was set to ∆t −1 = κ 2 .This value corresponds to roughly ten times the average feedback delay time between arrival of an input pattern and the conditional switching of the feedback logic upon arrival of the generated estimated state label ŷ.This time can be estimated as , where n is the index of the synaptic weight, G max is the amplifier gain range and κ A , κ QF , κ thresh and κ F are the line widths of the amplifier, quadrature filter, the combined thresholding circuit (cf. Figure 5) and the feedback Fredkin gates.There is a contribution scaling with n because the feedback traverses the individual weights sequentially to save power.When scaling up the perceptron to a higher dimension while retaining approximately the same input signal powers, it is intuitively clear that the combined 'inner product' signal amplitude s scales as s ∝ √ N s 1 , where s 1 is the signal amplitude for a single input.This allows to similarly scale up the amplitude ζ 0 of the signal encoding the generated estimated state label ŷ and consequently the bandwidth of the feedback Fredkin gates that it drives.A detailed analysis reveals that the Fredkin gate threshold scales as √ N , in particular we find that |χ|ζ 0 ∝ κ F ∝ |χ|ξ 0 ∝ κ thresh ∝ |χ|s ∝ N |χ|s 1 .The first two scaling relationships are due to the constraints on the Fredkin gate construction (cf.Appendix A.2.2), the next two scaling relationships follow from demanding that the additional thresholding resonator be approximately dynamically resonant at the highest input level (cf.Appendices A.2.1 and A.2.2).The last proportionality is simply due to the amplitude summation at the N -port beamsplitter.
This reveals that when increasing N the perceptron as constructed here would have to be driven at a lower input bit rate scaling as ∆t −1 ∝ N − 1 2 or alternatively be driven with higher signal input powers.A possible solution that could greatly reduce the difference in arrival time ∼ κ −1 F at each synapse could be to increase the waveguide-coupling to the control signal and thus decrease the delay per synapse.The resulting increase in the required control amplitude ζ 0 can be counter-acted with feedback, i.e., by effectively creating a large cavity around the control loop.When even this strategy fails one could add fan-out stages for ŷ which introduce a delay that grows only logarithmically with N .
Finally, we note that the bias power of all the Kerr-effect based models considered here scales inversely with the respective nonlinear coefficient {|ζ 0 | 2 , |s| 2 } × |χ| ∼ const when keeping the bandwidth fixed.This implies that improvements in the non-linear coefficient translate to lower power requirements or alternatively a faster speed of operation.

Conclusion and Outlook
In conclusion we have shown how to design an all-optical device that is capable of supervised learning from input data, by describing how tunable gain amplifiers with signal/bias isolation can be constructed from nonlinear resonators and subsequently combined with selfoscillating resonators to encode the programmed amplifier gain in their oscillation phase.By considering a few additional nonlinear devices for thresholding and all-optical switching we then show how to construct a perceptron, including the perceptron feedback rule.To our knowledge this is the first end-to-end description of an all-optical circuit capable of learning from data.We have furthermore demonstrated that despite optical shot-noise it nearly attains the performance of the optimal software algorithm for the classification task that we considered.Finally, we have discussed the relevant time-scales and pointed out how to scale the circuit up to large input dimensions while retaining the signal processing bandwidth and a low power consumption per input.
Possible applications of an all-optical perceptron are as the trainable output filter of an optical reservoir computer or as a building block in a multi-layer all-optical neural network.
The programmable amplifier could be used as a building block to construct other learning models that rely on continuously tunable gain such as Boltzmann machines and hardware implementations of message passing algorithms.
An interesting next step would be to design a perceptron that can handle inputs at different carrier frequencies.In this case wavelength division multiplexing (WDM) might allow to significantly reduce the physical footprint of the device.
A simple modification of the perceptron circuit could autonomously learn to invert linear transformations that were applied to its input signals.This could be used for implementing a circuit capable of solving linear regression problems.In combination with a multi-mode optical fibers such a device could also have applications for all-optical sensing.
Finally, an extremely interesting question is whether harnessing quantum dynamics could lead to a performance increase.We hope to address these ideas in future work.

A.2 Resonator Models
We consider resonator models with m internal modes and n external inputs and outputs.We assume for simplicity that a = 0 and c = 0 meaning that we will model all coherent displacements explicitly in the fashion described above.We also assume that their scattering matrices are trivially given by D = 1 n which means that far off-resonant input fields are simply reflected without a phase shift.Furthermore, none of our assumed models feature linear coupling between the internal cavity modes.This implies that the A-matrix is always diagonal.We are always working in a rotating frame.

A.2.1 Single mode Kerr-nonlinear Resonator
A Kerr-nonlinearity is modeled by the nonlinear term A Kerr NL (α) = −iχ|α| 2 α which can be understood as an intensity dependent detuning.The A-matrix is given by ( , where the total line width is given by n j=1 κ j = κ T and the cavity detuning from any external drive is given by ∆.The C-matrix is given by where the detuning differs slightly ∆ = ∆ + χ as can be shown in the derivation of the Wigner-formalism.[41] The special case of a single mirror with coupling rate κ and negligible internal losses is of interest for construsting the phase sensitive amplifier described in Section 2.1.Considering again an input given by a large static bias and a small signal = 1 √ 2 ( 0 + δ ), the steady state reflected amplitude is to first order For negligible internal losses we can give provide exact expressions for η, g + and g − .Rather than parametrizing these by the bias 0 we parametrize them by the mean coherent intra-cavity amplitude α 0 .When the system is not bi-stable (see below) relationship (20) defines a one-to-one map between 0 and α 0 .
The model matrices are and the corresponding SLH model is with ∆a/b = ∆ a/b + χ a/b + χ ab 2 and where the Wigner-correspondence We briefly summarize how to construct a controlled phase shifter using an ideal twomode Kerr cavity with a single input coupling to each mode and negligible additional internal losses.We exploit that in this case the reflected steady state signal amplitude ζ is identical to the input amplitude ζ up to a power dependent phase shift We assume that the control input amplitude takes on two discrete values ξ = 0 or ξ = ξ 0 and that variations of the signal input amplitude are small |ζ| ≈ |ζ 0 |.In this case a good choice of detunings and coupling rates is given by in addition to two inequality constraints that ensure that the system is stable.This construction ensures that = −1 and in fact it can easily be generalized to the more realistic case of non-negligible internal losses.
Finally note that the inequality constraints imply that the lower bounds for the input couplings scale as κ min a , κ min b ∝ |ζ 0 | which is important for our power analysis in Section 3.1.This, in turn implies that ξ 0 ∝ |ζ 0 | which is a fairly intuitive result.
The controlled phase shifter can now be included in one arm of a Mach-Zehnder interferometer to create a Fredkin gate (cf.Section 2.4).
To realize a thresholder, the control mode input is prepended with a two port Kerrcavity with parameters chosen such that it becomes dynamically resonant with maximal differential transmission gain close to where its output gives the correct high control input ξ 0 .
Overall, we remark that even when we account for the prepended cavity, the relationship c ∝ |ζ 0 | still holds, where c is the input to the thresholder.To see how the total decay rate of the thresholding cavity κ thresh scales consider first that to get maximum differential gain or contrast, we ought pick a detuning right at or below the Kerr stability threshold ∆ ≈ ∆ th = √ 3κ thresh /2.We choose the maximum input amplitude such that it approximately achieves dynamic resonance within the prepended thresholding cavity.This occurs when ∆ = −χ|α 0 | 2 (cf.Appendix A.2.1) and at an input amplitude of c ∝ κ thresh ∆ χ ∝ κ thresh .

A.2.3 NOPO model
The NOPO model has consists of three modes, the signal and idler modes α s , α i and the pump mode α p .We assume a triply resonant model4 and that ω s + ω i = ω p , allowing for resonant conversion of pump photons into pairs of signal and idler photons and vice versa.The nonlinearity is given by and the model matrices are Here, the SLH model is given by where now a, b and c correspond to α s , α i and α p .
A steady state analysis of the system driven only by a pump input amplitude reveals that below a critical threshold | | < th = As an interesting consequence of the model's symmetry there exists not a single above threshold state but a whole manifold of fixpoints parametrized by a correlated signal and idler phase where the common phase φ 0 is fixed by the pump input phase via In particular, for < 0 we have α i = α * s .Above threshold the system will rapidly converge to a fixpoint of well-defined phase φ.Without quantum shot noise φ would remain constant.With noise, however, the system can freely diffuse along the manifold.When the pump bias input is sufficiently large compared to threshold and consequently there are many signal and idler photons present in the cavity at any given time (|α s/i | 2 1) one can analyze the dynamics along the manifold and of small orthogonal deviations from the manifold.In the symmetric case considered here where signal and idler have equal decay rates, the differential phase degree of freedom φ = arg α i −arg αs It is relatively straightforward to generalize these results to a less symmetric model with different signal and idler couplings and even non-zero detunings, but for a given nonlinearity the model considered here provides the smallest phase diffusion and thus the best analog memory.For a very thorough analysis of this model we refer to [21].

A.3 Composite component models
Due to the scope of this article, we will refrain from including the full net lists for the composite component models in this article and instead publish them online at [47].We remark that composing a photonic circuit from the above described non-linear photonic models is often complicated by the fact that the steady state input-output relationships are hard or even impossible to invert analytically.A systematic approach to optimizing component parameters would be highly desirable.

Figure 2 :
Figure 2: (a)  shows two identical single mode Kerr-nonlinear optical resonators symmetrically placed in the two arms of an interferometer.(b) gives the phase sensitive amplifier gain g rr ( 0 ) (green, solid) and the g ir ( 0 ) (red, dashed) as a function of the bias photon input rate normalized by the drive power at which dynamic resonance occurs.For completeness we also provide g ri (black X's) and g ii (black dots).The detuning has been chosen such that g max

Figure 3 :
Figure 3: The NOPO's signal output ξ =√ κα s lives on a circular manifold parametrized by Φ (a, upper figure).Vacuum input shot noise leads to small fluctuations perpendicular to the manifold and diffusion along it.Mixing this signal output with a constant bias offset on a beamsplitter produces two outputs with anti-correlated total amplitude (a, lower figure).When both outputs are used to drive a complementary pair of tunable amplifiers whose outputs are subtracted, the overall real-to-real quadrature gain (green) of the system varies from positive to negative values (b).We can also see that the real-to-imaginary gain (dashed red) stays small for all NOPO phases, which allows us to efficiently subtract it downstream by the quadrature filter.The imaginary to real and imaginary gains are also plotted.

Figure 4 :
Figure4: Synapse circuit composed of a programmable amplifier and feedback logic (cf.Section 2.4) that implements the perceptron learning feedback (3) for a single weight.The upper amplifier when biased optimally leads to positive gain whereas the lower amplifier leads to negative gain due to the additional π phase shift.

Figure 5 :
Figure 5: In the upper graphic of (a) we present a schematic for Fredkin gate based on a two mode cross-Kerr-nonlinear resonator.The lower graphic shows how this circuit can be pre-pended with a single mode nonlinear resonator to better approximate a thresholding response.In (b) we present the input output characteristic of the prepended resonator (upper left), the Fredkin gate (upper right) and the combined input output relationship between the inner product amplitude s and the estimated state label ŷ.

Figure 6 :
Figure 6: Single trajectory divided into a training interval 0 ≤ t ≤ M train ∆t during which the learning feedback is active and a test interval M train ∆t < t ≤ M test ∆t.During training and testing, respectively, the system is driven by M train = M test = 100 separate input states which are held constant for an interval ∆t = 2κ −1 .The estimated class label is discretized by averaging the output intensity over each input interval, dividing the result by the intensity |ζ| 2 corresponding to the logical '1' output state and rounding.The upper panel compares the correct class label y (green) with the estimated class label ŷ (black) during training and testing, respectively.The area between them indicates errors or at least lag of the estimator and is shaded in light red.The second panel shows occurrences of classification errors (red vertical bars).The slight shading near the beginning and the end of the trajectory in the second panel visualizes the segments corresponding to the upper left and right panel, respectively.The third panel shows the learned linear amplitude gains for each synapse.After the learning feedback is turned off at t = M train ∆t, they diffuse slightly due to optical shot noise.

7 Figure 7 :
Figure 7: Projection of training data and classification boundaries.The data has been rotated such that the s 1 coordinate lines up with the learned normal vector of the separating hyperplane.Incorrectly classified data are plotted in red.The faint blue (red) lines visualize the evolution of the classifier boundary during training (testing).
∆t in units of [ −1 ] Error rate vs. learning paramaters

Figure 8 :
Figure 8: The perceptron's error rate vs the difficulty of the classification task and as a function of the parameters determining the learning rate.In Figure (a) we compare the unoptimized performance of the perceptron circuit (red diamonds) to the optimal performance bound (solid, green) as well as a GDA (blue X's) trained on the same number of training examples.We show averages over 100 trials at each cluster separation.The GDA data was similarly averaged over 100 trials.The transparent envelopes indicate the sample standard deviation.The black dots show the perceptron performance when simulated without shot noise.We see that the shot noise has very little effect.In Figure (b) we plot the average error rate (averaged over 50 trials) at fixed cluster separation µ 1 − µ 0 2 /σ = 2 for various values of the time interval ∆t for which each data sample is presented to the circuit as well as the strength of the training feedback α.The total number of feedback photons N f b = |α| 2 ∆t per sample is constant along the faint dashed lines and the actual value is indicated on the right.A good choice of parameters is characterized both by low feedback power (small |α| 2 ) and high input rate (low sample time ∆t) while still resulting in a low classification error rate.The X marks the parameters used for the results in (a) and the previous Figures.