abstract: In this paper we review `THELI` (Erben & Schrimer, 2005), an image processing pipeline developed to reduce multi-pointing optical images taken by mosaic CCD cameras. This pipeline works on raw images by removing several instrumental contaminations, implementing photometric calibration and astrometric alignment, and constructing a deep co-added mosaic image complemented by a weight map. We demonstrate the procedure of reducing NGC 3923 images from raw data to the final results. We also demonstrate the quality of our data reduction strategy using mag-count and mag-error in mag plots. Emphasis is mainly placed on photometric calibration which is of great interest to us due to our scientific case. Based on the cross-association of the extracted catalogue against a reference catalogue of stellar magnitudes, zero-point calibration is performed. Our data reduction strategy and the method employed for cross-correlating large catalogues is also presented.
  **Key words:** methods: data analysis – techniques: image processing
author: *R. Joveini$^{1,2}$[^1], S. Sotoudeh$^{1,2}$, A. Roozrokh$^{2,3}$, M. Taheri$^{1}$*
title: **Using THELI pipeline in order to reduce Abell 226
  multi-band optical images**

$^{1}$Physics Department, Sharif University of Technology, Azadi Ave., Tehran, Iran
$^{2}$School of Astronomy, Institute for Research in Fundamental Sciences, Opposite Araj, Artesh Highway, Tehran, Iran
$^{3}$Physics and Astronomy Department, University of California Riverside, 900 University Ave., Riverside, CA 92521, USA

# introduction

In astronomy, raw CCD images from telescopes cannot be directly used for scientific purposes. Firstly, several instrumental effects must be removed. Generally speaking, data reduction is the transformation of raw data into a form suitable for analysis. The following processes are required to achieve this goal:

-   removal of instrumental signatures, such as bias offset, dark currents, field curvature (caused by projecting the spherical sky onto a flat CCD plane), and fringe patterns;

-   masking of unwanted signals, such as cosmic rays, stellar halos and satellite tracks;

-   photometric and astrometric calibration;

-   co-addition of individual frames.

The `THELI` (Transforming HEavenly Light into Image)[^2] pipeline was initially developed for WFI cameras (it consists of 8 CCD chips of 2k$\times$`<!-- -->`{=html}4k each)[^3] mounted on the ESO 2.2 meter Max Planck telescope. It has a modular design allowing it to be adapted to other single- or multi-chip cameras with considerable ease.

The primary goal of developing the `THELI` pipeline was to reduce weak lensing data; therefore, more emphasis was laid on the accurate alignment of galaxies for each exposure (precise astrometry, rather than photometry), acquiring the highest possible resolution and accurate noise mapping.

Through the course of the data reduction process the `THELI` pipeline uses well-tested astronomical software. This allows for easy exchange whenever a new algorithm or a better implementation becomes available. The preliminary tools in the `THELI` pipeline are the `LDAC`[^4] software , the `TERAPIX` software , `Eclipse` and `qfits` tools[^5] and `IMCAT` utilities[^6].

Next, the processing a set of optical images in the ESO bands B, R, and I is described. Our initial data set consisted of $30$ Gigabytes of raw exposures: `SCIENCE` frames of 7 different galaxy groups and calibration frames taken in 3 successive nights with WFI at ESO 2.2m[^7]. Prior to the reduction procedure all objects are treated in the same manner, i. e. we suppose the same calibration frames for all of the `SCIENCE` frames.

# pre-reduction

Algorithms in the pipeline which remove instrument effects (such as bad CCD pixels and fringe patterns) and which can be considered constant during the period of our observation (3 nights), are described further.

Firstly, each file's header is updated with the necessary keywords for the pipeline. The image is then divided into the number of chips in the CCD (which constitutes 8 CCD chips in a WFI mosaic). From this step on, the pipeline works on individual chips rather than whole images, thereby enhancing the speed and enabling us to do multi-chip processing on multi CPUs.

## bias and dark frame

In the first step, following a preliminary inspection of all exposures of a given type (bias, flat field), the pipeline identifies a typical count level and rejects outliers, e. g. `DARKs` with too-short exposure time or over-saturated `SKYFLATs`. The acceptable range is defined by the user. Since ESO WFI is constantly cooled to a stable temperature of 167 K and dark current is negligible, many observers do not take `DARK` frames. We will describe their usage when appropriate, however it should be noted that we have not had or processed DARK frames.

Each frame is overscan-corrected (OC) and trimmed: overscan region is trimmed off the image. Master `BIAS` and master `DARK` frames are created by (median or arithmetic) averaging of individual `BIAS` and `DARK` frames. The pipeline uses master `DARK` to identify bad pixels.

## flat-field pattern

In general, the sensitivity and the illumination of a CCD is not homogeneous. Sensitivity can change from pixel to pixel, while the shift in illumination is considerable only at larger scales of distance. To make surface brightness homogeneous, we utilise a flat-field pattern. Due to the dependence of the flux of radiation of astronomical objects and the sky background on the filter used, the tasks described below need to be carried out separately for each filter.

## manual inspection, mask creation

An 8$\times$`<!-- -->`{=html}8 binned mosaic of corrected `SCIENCE` frames is created to check the run process. At this stage, we looked at binned mosaics to check if pre-reduction was performed correctly. Using `DS9` software, we manually omitted out-of-focus data, and masked extended defects like satellite tracks and bright star reflections.

## creating weight frames

The pipeline creates a weight frame for each `SCIENCE` frame. Hot/cold pixels are detected by studying the master `DARK`, saturated pixels are identified by thresholding the `SCIENCE` frames; cosmic rays are discovered by `SExtractor` in connection with `EyE` , and manual masks are added using the `LDAC` utilities.

Global `Weight` and `Flag` frames are made for each CCD chip. Flag frames are integer `FITS` in which 0 denotes good pixels and every other value denotes a certain defect. The values are used when producing weights. Global `Weights` contain information about bad pixels of all images from that chip.

# reduction

We group `SCIENCE` frames into sets, depending on the objects they contain. Our pointings are: HCG 48, HCG 62, HCG 67, NGC 3557, NGC 3923, NGC 4697 and RX-J2114.3-6800. We run the reduction process on each pointing and subsequently add the reduced individual frames.

## astrometery

The initial step in astrometery is to detect high S/N objects using `SExtractor` and to generate a catalogue of non-saturated stars. By comparing this catalogue to the USNO-B1 catalogue, a zero-order, single shift astrometric solution is calculated for each image. The CCDs in multi-chip cameras can be rotated unintentionally with respect to each other. In addition, due to a large field of view, the sky must be considered to be a spherically curved surface.

The next step is to estimate third-order polynomials for the astrometric solution for each chip, using the `SCamp` package developed by `TERAPIX`.

## photometry

Exposures are taken under varying conditions: parameters such as airmass and background radiation differ from one night of observation to another. Therefore, during the first part of photometric calibration, images should be calibrated relatively. This is done by the `LDAC relphotpm` program. `Relphotom` takes tables of overlapping exposures as input and calculates the mean deviation of magnitudes: $$M_{k,j}=\frac{\sum\limits_{i}\left(\sigma^{2}_{K}+\sigma^{2}_{J}\right)^{-1}\left(M_{K_{i}}-M_{J_{i}}\right)}{
\sum\limits_{i}\left(\sigma^{2}_{K}+\sigma^{2}_{J}\right)^{-1}},$$ where $K$ and $J$ $(K \neq J)$ are fields, $i$ denotes objects present in both exposures, and $\sigma$ are measurement errors of the magnitude, and finds the relative zero point magnitude by $\chi^{2}$ minimisation: $$\chi^{2}=\sum\limits_{k,j}^{N}\left[M_{k,j}-\left(ZP_{k}-ZP_{j}\right)\right]^2.$$ In this case we neglect variant photometric conditions which affect each spectral type in a different way.

# co-addition

## preparation for co-adding

Sky background is calculated using `SExtractor BACKGROUND` check image for every large-object-subtracted frame, and is subtracted from all `SCIENCE` images. A re-sampled image is made using the astrometric solution polynomials calculated in astrometry step and stored in each chip's header.

## co-addition of individual frames

offers two tools for image co-adding: `SWarp` and EIS `Drizzle`. Our tool of choice is the former. Using all input images (which are related to a single output pixel) in our sample, `SWarp` calculates the final results using the weighted mean method.

A `WEIGHT` image is also produced, as well as a `FLAG` image. `WEIGHT` image plays a key role in source detection of the final image , for a comparison between weighted and un-weighted source detection.

# our method of catalogue cross association

As described above, we need to match object information from different channels. Generally there are two cases when it is necessary to consult two or more catalogues:

1.  When there is given a catalogue in a particular filter and it is desired to cross-match it with a reference catalogue, like a Standard Star Magnitude catalogue.

2.  When there are multiple observations of a source in different filters. In this case, one needs to deal with multiple channels (in our case: B, R and I).

Since `SExtractor`'s detection is not perfect in terms of source coordinates, one has to take one catalogue as a reference catalogue and treat the others as search catalogues; therefore, for each object in a certain channel, information from the other channels will be found and added, as to make a "matched and merged" catalogue.

# results and qualifications

With the final `COADD` images along with their `WEIGHTs` in hand in B, R and I filters, one would produce several plots to show the qualification of data reduction. Throughout this, two of them are very important: mag-count histogram and mag-error in mag scatter plot. As shown in Fig.  we have plotted the mag-count histogram for NGC 3923 field of galaxies (note that stars have been separated from galaxies using `SExtractor`'s `CLASS_STAR` parameter larger than 0.95 as a criteria. Seven outliers have been removed, since they were only round-shaped galaxies). As seen, the count drops from magnitude 22.5; this is called completeness limit. It shows that our data obtained with this instrument is trustworthy up to this completeness limit (note that the count should be raised with respect to the fainter objects).

The other plot, which is important in astronomical data reduction, is the mag-error in mag scatter plot as we showed in Fig. . This plot reveals which data is trustworthy and which data is not based on our scientific goal. It demonstrates that for objects with magnitude around 22.5 the error in magnitudes increase very fast; therefore objects fainter than 22.5 are not suitable for this kind of investigation.

As a fundamental parameter in astronomy photometric data, seeing[^8] associated with the individual pointings (in R band) ranged from 0.75 to 1.1 arcsec, and the average seeing of the co-added image has been measured to be 0.89 arcsec.

# acknowledgement

The authors acknowledge IPM for providing computational facilities and also appreciate Reza Mansouri, Habib G. Khosroshahi and Alireza Molaeinezhad for useful discussions and guidance.

[^1]: email@example.com

[^2]: to be obtained from `http://astro.uni-bonn.de/``mischa/theli.html`

[^3]: for more information, see: `http://www.eso.org/sci/facilities/lasilla/instruments/wfi/index.html`

[^4]: Leiden Data Analysis Center, available at: `ftp://ftp.strw.leidenuniv.nl/pub/ldac/software`

[^5]: available at: `http://www.eso.org/projects/aot/eclipse`

[^6]: `http://www.ifa.hawaii.edu/``kaiser/imcat/`

[^7]: ESO Programme ID of the observations: 077.A-0747(A) on April 4, 2006

[^8]: calculated using FWHM in an area around image centre


abstract: **NOTE: this paper has been published in Nature Communications and can be accessed publicly using [this link](https://doi.org/10.1038/s41467-020-18098-0)**.
  .
  Artificial neural networks are notoriously power- and time-consuming when implemented on conventional von Neumann computing systems. Consequently, recent years have seen an emergence of research in machine learning hardware that strives to bring memory and computing closer together. A popular approach is to realise artificial neural networks in hardware by implementing their synaptic weights using memristive devices. However, various device- and system-level non-idealities usually prevent these physical implementations from achieving high inference accuracy. We suggest applying a well-known concept in computer science—committee machines—in the context of memristor-based neural networks. Using simulations and experimental data from three different types of memristive devices, we show that committee machines employing ensemble averaging can successfully increase inference accuracy in physically implemented neural networks that suffer from faulty devices, device-to-device variability, random telegraph noise and line resistance. Importantly, we demonstrate that the accuracy can be improved even without increasing the total number of memristors.
author: D. Joksas$^{1}$[^1]; P. Freitas$^{2}$; Z. Chai$^{2}$; W. H. Ng$^{1}$; M. Buckwell$^{1}$; C. Li$^{3}$; W. D. Zhang$^{2}$; Q. Xia$^{3}$; A. J. Kenyon$^{1}$; A. Mehonic$^{1}$`<!-- -->`{=html}
title: Committee machines—a universal method to deal with
  non-idealities in memristor-based neural networks

# Introduction

Artificial neural networks (ANNs), with all of their variants, are now the main tools in machine learning tasks, such as classification. The vast amounts of data being constantly produced have enabled successful training and operation of ANNs. However, to achieve high inference accuracy, it is usually necessary for neural networks to have a large number of parameters. This results in both training and inference stages being time- and power-consuming. This is largely caused by the need to transfer data from memory to computing units—physical separation of memory and computing is the essence of any von Neumann system.

One of the most promising solutions to these problems is the paradigm of non-von Neumann computing and, specifically, analogue implementations of synapses (weights) in physical ANNs. Because there are many more synapses than there are neurons in ANNs, the matrix-vector multiplications, in which the synaptic weight values are used, are the costliest operations in these networks, both in terms of power and time. Computing directly in memory would minimise data transfers from off-chip memory, thus the most popular approach is using analogue memory devices as proxies for synaptic weights of ANNs (both fully connected and their variants ). A common technique is to arrange such devices in a structure, called crossbar array, in which every device (or a pair of devices) is used to represent a single synaptic weight or, more generally, an entry in a matrix . Memristive devices, such as phase-change memories (PCMs) or resistive random-access memories (RRAMs) , have been considered as candidates for such tasks. Although here we focus on ex-situ training, such systems have been successfully utilised for in-situ training too .

```latex
\begin{table*}
\begin{tabular}{|c|c|c|c|}
\hline
  \textbf{\begin{tabular}[c]{@{}c@{}}First author \\ (year)\end{tabular}}                      & \textbf{Non-ideality}         & \textbf{Device type}                                                     & \textbf{Proposed solution}                                                  \\ \hline
  \begin{tabular}[c]{@{}c@{}}C. Sung \\ (2018) \cite{sung_2018}\end{tabular}      & Current/voltage non-linearity & \ce{TaO_x} RRAM                                                          & Hot-forming step is adopted                                                 \\ \hline
  \begin{tabular}[c]{@{}c@{}}C. Li \\ (2018) \cite{li_2018_a}\end{tabular}      & Current/voltage non-linearity & \ce{Ta}/\ce{HfO2} RRAM                                                   & 1T1R architecture is adopted                                                \\ \hline
  \begin{tabular}[c]{@{}c@{}}Y. Fang \\ (2018) \cite{fang_2018}\end{tabular}      & Device-to-device variability  & \ce{HfO_x} RRAM                                                          & \begin{tabular}[c]{@{}c@{}}Ultra-thin ALD-\ce{TiN}                          \\ buffer layer is introduced\end{tabular}             \\ \hline
  \begin{tabular}[c]{@{}c@{}}B. Govoreanu \\ (2013) \cite{govoreanu_2013}\end{tabular} & Device-to-device variability  & \ce{Al2O3}/\ce{TiO_2} (VMCO) RRAM                                        & \begin{tabular}[c]{@{}c@{}}Non-filamentary RRAM is adopted\end{tabular}     \\ \hline
  \begin{tabular}[c]{@{}c@{}}A. J. Kenyon \\ (2019) \cite{kenyon_2019}\end{tabular}    & Device-to-device variability  & \ce{SiO_x} RRAM                                                          & \begin{tabular}[c]{@{}c@{}}The roughness of bottom                          \\ electrodes is increased\end{tabular}                \\ \hline
  \begin{tabular}[c]{@{}c@{}}L. Xia \\ (2017) \cite{xia_2017}\end{tabular}       & Faulty devices                & -                                                                        & \begin{tabular}[c]{@{}c@{}}A modified mapping algorithm                     \\ and redundancy schemes are used\end{tabular}        \\ \hline
  \begin{tabular}[c]{@{}c@{}}S. Ambrogio \\ (2018) \cite{ambrogio_2018}\end{tabular}  & Limited dynamic range         & PCM                                                                      & \begin{tabular}[c]{@{}c@{}}Two pairs of conductance of varying significance \\ for every synaptic weight are used\end{tabular}     \\ \hline
  \begin{tabular}[c]{@{}c@{}}M. Hu \\ (2016) \cite{hu_2016}\end{tabular}        & Line resistance               & -                                                                        & \begin{tabular}[c]{@{}c@{}}Advanced mapping algorithms are used to          \\ compensate for line resistance effects\end{tabular} \\ \hline
  \begin{tabular}[c]{@{}c@{}}W. Wu \\ (2018) \cite{wu_2018}\end{tabular}        & Programming non-linearity     & \ce{HfO_x} RRAM                                                          & \begin{tabular}[c]{@{}c@{}}Electro-thermal modulation layer is              \\ deposited on the switching layer\end{tabular}       \\ \hline
  \begin{tabular}[c]{@{}c@{}}J. Woo \\ (2016) \cite{woo_2016}\end{tabular}       & Programming non-linearity     & \ce{HfO2} RRAM                                                           & Bilayer structure is adopted                                                \\ \hline
  \begin{tabular}[c]{@{}c@{}}S. Ambrogio \\ (2018) \cite{ambrogio_2018}\end{tabular}  & Programming non-linearity     & PCM                                                                      & \begin{tabular}[c]{@{}c@{}}PCM devices are used together                    \\ with CMOS transistors\end{tabular}                  \\ \hline
  \begin{tabular}[c]{@{}c@{}}Z. Chai \\ (2018) \cite{chai_2018_a}\end{tabular}    & Random telegraph noise        & \begin{tabular}[c]{@{}c@{}}\ce{TiO2}/a-\ce{Si} (aVMCO) RRAM\end{tabular} & \begin{tabular}[c]{@{}c@{}}Non-filamentary RRAM is adopted\end{tabular}     \\ \hline
\end{tabular}
\caption[Examples of past efforts at dealing with non-idealities of memristive devices and their systems.]{\textbf{Examples of past efforts at dealing with non-idealities of memristive devices and their systems.} }
\label{tab:past_efforts}
\end{table*}
```

In memristive implementations of ANNs, the main concern is that various non-idealities associated with these devices can prevent these systems from achieving high accuracy . Examples of non-idealities affecting inference accuracy include, but are not limited to, devices not being able to electroform, devices stuck in one of the resistance states after electroforming, device-to-device (D2D) variability and random telegraph noise (RTN). When training analogue systems in-situ, limited endurance and non-linear resistance modulation too have to be taken into account. To mitigate the effects of these device non-idealities, it is often necessary to modify device structure , to use more advanced programming schemes or to use additional circuitry or high-precision processing units in conjunction with memristive elements. On the system level, there is an issue of line resistance which affects the distribution of currents and thus decreases the accuracy. These line resistance effects can be partially compensated for algorithmically or partially mitigated by using multiple smaller crossbar arrays . Examples of past efforts at dealing with these and other non-idealities of memristive devices and systems are listed in Table ; most of these non-idealities are still the main focus of the research in the neuromorphic community.

We propose a simple way to mitigate the effects of all types of non-idealities during inference. We suggest combining several non-ideal memristor-based neural networks into committees to achieve better accuracy. The committee machine (CM) method we propose significantly increases the inference accuracy and does not increase the computation time because memristive ANNs in such committees work in parallel.

In this work, we firstly explain the simulation setup—what networks were trained, how they were simulated and how they were combined into CMs. After that, follows the experimental part. We investigate three different types of memristor technology—tantalum/hafnium oxide-based (/), tantalum oxide-based (), and amorphous vacancy modulated conductive oxide-based (aVMCO) devices. By exploring their non-idealities relevant to inference—faulty devices, D2D variability, RTN, and line resistance—we use the experimental data to simulate memristive ANNs working individually and in committees.

# Results

## Simulation setup

Fully connected ANNs were trained in software to recognise handwritten digits (using MNIST data base ). Architectures with one hidden layer were explored. Unless stated otherwise, the simulations used networks with 25 hidden neurons. However, networks with 50, 100 and 200 hidden neurons were additionally employed to evaluate the effectiveness of the proposed method while controlling for the total number of memristors required. Following training, weights of ANNs were mapped onto pairs of conductances using proportional mapping scheme (see ) to simulate memristor-based ANNs. Finally, these memristive networks were disturbed using experimental data to reflect the effect of device- and system-level non-idealities.

After simulating physical non-idealities, the networks were combined into CMs that employed ensemble averaging (EA) . The principle of EA is shown in Figure a—several networks are combined in parallel and then their outputs are averaged. After that, the prediction is made using the averaged vector—the prediction is the label corresponding to the largest entry in the vector.

CM methods are frequently used even with conventional ANNs. Methods, such as EA, often produce better accuracy than that of the best individual network in a committee . Although there are other types of CMs besides EA, they often rely on training additional gating networks or boosting networks during the training stage. Using a gating network in this scenario would produce additional problems—to avoid it acting as a performance bottleneck, it too would have to be implemented on crossbar arrays. Various non-idealities would decrease the effectiveness of this gating network which is responsible for making the decisions about the whole committee of ANNs. Likewise, we speculate that boosting of networks would not be feasible in ex-situ training because it requires information about where individual ANNs perform poorly—this cannot be known precisely until they are implemented physically on crossbar arrays and the non-idealities manifest themselves. To authors' best knowledge, the application of boosting in the context of memristive neural networks seems to have been explored only once before ; as expected, it requires training each memristive implementation differently because non-idealities manifest themselves differently in different crossbar arrays.

There exist modifications of EA algorithm that could potentially perform better. One example of this is generalized ensemble method (GEM) which, instead of using equal weightings for each network during averaging (as in EA), uses a different one for each network . These weightings are analytically determined by considering correlation of errors between different networks. But because only considered networks with mean square error loss function (while our networks used cross-entropy loss function), this work does not explore GEM. Instead, we investigated whether it is possible to achieve a better performance by optimising the weightings numerically. This method, like GEM and others previously mentioned, might be impractical because, firstly, these weightings could be determined only after the ANNs are physically implemented on crossbars, and, secondly, the devices could change throughout their lifetimes thus affecting the optimal weightings.

Even with the assumption that the devices would have perfect retention, we found that optimisation of weightings achieves effectively the same performance. Because of these reasons, we focus only on EA in the main text, but present our results of optimising weightings in Supplementary Figure 5. We stress that we are open to the idea that other CM methods besides EA could be utilised successfully for ex-situ training in the context of memristive ANNs. However, in this work we focus on demonstrating that CMs can be used to improve the accuracy of memristor-based ANNs in general.

With EA, we find that even when the memristive ANNs, which go into a committee, all use the same digital weights that are mapped onto crossbar arrays (see Figure b), committee of memristor-based networks can still achieve higher accuracy than just a single non-ideal network. Although all networks have the same *digital* weights before mapping, their physical implementations (which we call "disturbances" in Figures b,c because they can usually be represented by the modification of individual weights) will be different. For example, in one crossbar array, a certain set of devices will be faulty, while in the other crossbar array, it will be a different set. This will result in different physical implementations having slightly different learned representations of the data set, or, to paraphrase, different networks will be "damaged" differently by the non-idealities. This means that these committees will be able to combine different representations, and thus achieve higher accuracy. However, by definition, such approach would almost certainly not yield a committee accuracy that is higher than the accuracy of a single digitally implemented network.

A better approach is to use different digital networks for different physical implementations that go into a committee (see Figure c). This approach much more resembles the conventional application of EA in computer science. In the context of memristive crossbar arrays, it would not only help to mitigate the effects of the non-idealities (as in the case of Figure b), but would also allow to combine the representations of digital networks that were different even before the mapping stage. Most importantly, this method allows for a committee to achieve higher accuracy which is sometimes even higher than that of individual networks with digitally implemented weights. We thus used this method in this analysis. An example comparison of these two approaches is presented in Supplementary Figure 8.

In this work, any given committee used only one network architecture but each network was initialised differently before training, thus trained networks had different sets of weights. Although it was not explored in this work, combining different network architectures in a committee of memristor-based networks might be advantageous. Furthermore, in this work we focus on fully connected ANNs but CMs could be applied to other variants of neural networks as well. Due to the simplicity of EA, it could, for example, be employed in convolutional neural networks (CNNs) , which are often used for image classification. This might be of interest as CNNs have been successfully implemented using crossbar arrays recently . However, crossbar implementations are naturally more suited to fully connected networks, therefore we limit ourselves to this architecture but are open to exploring the effectiveness of EA with memristive CNNs in the future.

## / RRAM

With array-level data available, / experiments provide the most complete picture of device- and system-level non-idealities. In this subsection, we present not only the analysis of faulty devices and D2D variability, but also careful consideration of the line resistance effects. / memristors do not exhibit apparent RTN and overall have excellent retention properties , and thus are perfect candidates for inference application.

### Faulty devices and device-to-device variability

The most energy-efficient procedure to modulate the conductance of memristors is by the application of voltage pulses. In an ideal scenario, one would apply identical pulses and observe constant increases in conductance with each pulse. This is rarely the case in practise, but, fortunately, this type of behaviour is more relevant for in-situ training where it is necessary to ensure linear adjustment of ANN's weights . In ex-situ training, conductance verification schemes can be used to program the devices precisely. Because the devices would have to be programmed only once, one can spend additional resources to do so accurately by applying SET (potentiation) and RESET (depression) pulses until a desirable conductance state is achieved.

Even with this approach, there remain two obstacles—faulty devices and D2D variability. It is observed in most memristor technologies that at least a small fraction of the devices tends to get stuck in a particular conductance state. Additionally, even if not stuck, different devices might behave differently; for example, they might have different conductance ranges. Figure a shows conductance changes in / RRAM devices (in a $128 \times 64$ crossbar array) when they are applied with voltage pulses. We can see from the median values that overall the devices' conductance tends to increase as more SET pulses are applied. However, the wider bottom regions of the violin plots indicate that some devices are stuck around high resistance state (HRS) and cannot set entirely no matter how many voltage pulses are applied. There also exist devices that are stuck in low resistance state (LRS), or simply do not span the full conductance range.

Figure a combines data from multiple SET cycles for each of the memristors, thus it is important to understand how do these devices behave individually. Figures b-f show conductance of 5 (out of 8,192) devices over 11 SET and RESET cycles. In the five diagrams, the radial component represents the conductance (in  mS) and the angular component represents the number of applied pulses. Figure b shows an example of preferable (and typical) device behaviour—conductance changes in a continuous fashion and spans a wide range of conductance values, from $\sim$`<!-- -->`{=html}0.1 ms to $\sim$`<!-- -->`{=html}1.0 ms. Although RESET cycles tend to feature abrupt decreases in conductance, one can always repeat a cycle and exploit the more predictable behaviour of SET cycles.

When encoding continuous numbers into crossbar devices' conductances, it is often preferable to choose a large enough conductance range. Using data from Figure a, one could, for example, choose the range between the first and the last median points (from $\sim$`<!-- -->`{=html}0.1 mS to $\sim$`<!-- -->`{=html}1.0 mS). Device, whose behaviour is presented in Figure b, could be easily set to any conductance within that range, as we have seen before. On the other hand, device, whose behaviour is presented in Figure c, although operating in a predictable fashion, has smaller conductance range. We can see that in all cycles, its conductance does not exceed 0.8 mS. This is an example of D2D variability that can make it difficult to choose optimal operating range and set the conductance of all devices precisely.

Device, whose behaviour is presented in Figure d, shows high cycle-to-cycle variability. Although that could prove to be a problem in some applications, this specific device might perfectly serve its purpose in ex-situ training of ANNs. We can observe that this device spans the same conductance range as device from Figure b, even if in an unpredictable manner. Because all states in the full range are, in theory, achievable, one can cycle the device multiple times until it is set to the required conductance level.

Lastly, we have devices whose negative effect is most difficult to mitigate—faulty devices. Figure e shows behaviour of a device stuck at high conductance values, while Figure f shows behaviour of a device stuck at low conductance values. No matter how many pulses the devices are applied with or how many times they are cycled, they exhibit almost no conductance variation and thus, in most cases, cannot be used to encode information.

Knowing that some devices perform like the ones whose behaviour is shown in Figures c,e,f, it is important to minimise their negative effect. If the conductance that a device has to be set to is outside that device's range, it is sensible to set it to the closest achievable conductance. Although there is little that can be done about fully stuck memristors, it is possible to optimise the behaviour of devices like the one in Figure c that simply have smaller conductance range. For example, if such a device has to be set to 0.9 mS, one would set it to the highest achievable conductance ($\sim$`<!-- -->`{=html}0.8 mS). In the following simulations involving faulty devices and D2D variability, operating range between the first and the last median points was used, the devices were chosen randomly from the $128 \times 64$ crossbar and set to the most desirable states, as described in this paragraph.

### Line resistance

The effect of line resistance can be extremely detrimental in many crossbar-based implementations of ANNs. That is especially the case if the crossbars used are large and the resistance of the interconnects is high (compared to memristors' resistance). Because in a neural network many of the inputs are non-zero at any given time, a lot of current accumulates in the bit lines which results in significant voltage drops across the interconnects, and thus the current distribution across the crossbar is affected in a major way.

The / crossbar has shape $128 \times 64$ and so this shape was chosen for all the simulations involving line resistance. Even relatively small ANNs of architecture 784(+1):25(+1):10 would need $2 \times (785 \times 25 + 26 \times 10) = 39,770$ memristors to be implemented. Even if not all the inputs were used at any given time, it would not be possible to fit all the memristors onto a single crossbar of shape $128 \times 64$. To overcome this, we decided to simulate multiple crossbars, each of which would implement a subset of the synaptic weights, but, for a given synaptic layer, would all compute in parallel. Because $\lceil 785/128 \rceil = 7$, seven crossbars were used to implement the first synaptic layer; the first crossbar utilized bottom 113 word lines, while the other six crossbars used bottom 112 word lines because $113 + 6 \times 112 = 785$. The second synaptic layer was implemented using eighth crossbar utilizing its bottom 26 word lines.

Figure a shows an example of how the first synaptic layer of 784(+1):25(+1):10 neural network could be implemented. Specifically, it shows how the first subset of weights would be implemented using one of the crossbars. Because we use proportional mapping scheme, positive and negative weights would be implemented in different bit lines. In Figure a, memristors designated to implement positive weights are coloured in blue, memristors designated to implement negative weights are coloured in orange and unelectroformed memristors are coloured in black. Because simulations were constrained by experimental data, some of the devices were left unused and assumed to be unelectroformed. In practise, the crossbars could be manufactured to fit the geometry of the ANNs.

In each synaptic layer, the corresponding output currents from each of the crossbars would be added together. Additionally, output currents at the bit lines implementing negative weights would be subtracted from the output currents at the neighbouring bit lines (to their left) implementing positive weights. For example, in the example configuration of Figure a, output current at the $2^\mathrm{nd}$ bit line would be subtracted from the output current at the $1^\mathrm{st}$ bit line, etc.

Unfortunately, even when using multiple smaller crossbars, the interconnects can significantly disturb current distribution in the crossbar. Average output current decreases due to line resistance in all seven crossbars of / devices (whose resistance ranges from $\sim$`<!-- -->`{=html}1 k Ω to $\sim$`<!-- -->`{=html}11 k Ω, and their interconnect resistance is 0.35 Ω and 0.32 Ω in the word and bit lines, respectively), are shown in the heatmap in Figure b. We can see that the current decreases can range from $\sim$`<!-- -->`{=html}12% at the outputs nearest to the applied voltages to $\sim$`<!-- -->`{=html}16% at the outputs in the rightmost bit lines that are used. In Supplementary Note 1, we provide a possible strategy of mitigating line resistance effects in supervised learning. This scheme was not employed in the simulations described in the main text because we wanted to find out how well the CM method would deal with noticeable line resistance effects.

### Inference accuracy

Figure  shows the accuracy of individual networks, as well as of their committees; memristive ANNs were simulated by taking into account three non-idealities of / crossbar explored earlier—faulty devices, D2D variability and line resistance. As indicated by the yellow box plot in Figure , individual networks implemented digitally achieve $\sim$`<!-- -->`{=html}95.9% median accuracy. Networks disturbed to reflect the effect of non-idealities achieve $\sim$`<!-- -->`{=html}91.0% median accuracy, as indicated by the vermilion box plot. Although that is a substantial drop in accuracy, we see that as more networks are added to the committee, the more the accuracy increases. When 5 networks are used in a committee, median accuracy increases up to $\sim$`<!-- -->`{=html}95.7%, as indicated by the rightmost green box plot.

##  RRAM

In order to explore the effectiveness of minimising adverse effects of RTN, we use another memristor technology based on . To investigate RTN, measurements from a single device were considered. To simulate line resistance effects, interconnect resistance from / was used and the same crossbar shape was assumed.

### Random telegraph noise

Memristors often suffer from RTN resulting in a different accuracy at any given instant in time. device was characterised by measuring the current of 8 resistance states multiple times. Figure  shows the cumulative probability plots for those resistance states, together with lognormal fits modelling the nature of RTN. One of the things that the figure reveals is that higher resistance states suffer from higher degree of RTN. Fits for every resistance state, together with occurrence rates (see Supplementary Table 2), were used to disturb the weights of ANNs in order to reproduce the effect of RTN.

### Inference accuracy

The results combining RTN and line resistance effects for device are shown in Figure . From the difference in median accuracy between yellow and blue box plots, we can notice that there is a significant drop in accuracy simply due to mapping of weights onto conductances. That is not surprising given that only 8 states were available for mapping. One can also observe that further drop in median accuracy due to non-idealities is not as severe—it drops to $\sim$`<!-- -->`{=html}94.1%. The RTN disturbance magnitude is limited to $<$`<!-- -->`{=html}100% in most cases, which possibly contributes to its smaller effect on accuracy. Additionally, device has much higher resistance (ranging from 25 k Ω to 200 k Ω), thus line resistance is also less of a concern. When non-ideal networks are combined into committees of 5, the median accuracy jumps to $\sim$`<!-- -->`{=html}96.5%—even higher than the software baseline of individual networks. This reveals additional trend seen in all the simulations performed—the higher the accuracy of the individual non-ideal memristive networks, the higher the accuracy of the committees that they are part of.

##  RRAM

Further, we consider a third memristor technology—one based on aVCMO materials. We test the effects of RTN by considering measurements from a single device. Line resistance effects were simulated by using interconnect resistance and shape of / crossbar array.

### Random telegraph noise

Figure  shows the cumulative probability plots for 8 resistance states of an aVMCO device suffering from RTN. Like in , we observe that higher resistance states experience RTN of higher magnitude. However, compared to , the RTN magnitude is much more predictable. Fits for each of the 8 resistance states, together with occurrence rates (see Supplementary Table 3), were used to simulate the effect of RTN in aVMCO-based neural networks.

### Inference accuracy

The results combining RTN and line resistance are shown in Figure . As with , we see a large drop due to mapping onto conductances—consequence of very few states available for mapping. More interestingly, the accuracy of individual memristor-based networks with and without non-idealities is almost identical. That is because the occurrence rate of RTN in aVMCO device is small and there is a much smaller probability of RTN having large magnitude. Additionally, resistance of aVMCO device is even higher than that of device—it ranges from 1 M Ω to 7.5 M Ω. Therefore, line resistance has even a smaller effect in a hypothetical array of aVMCO devices. Due to median accuracy of individual non-ideal memristor-based networks being higher ($\sim$`<!-- -->`{=html}94.6%), the median accuracy of committees is higher too—in committees of size 5 it increases to $\sim$`<!-- -->`{=html}96.7%.

# Discussion

The results from the previous section suggest that the method of using committee machines to improve the accuracy of memristive neural networks is technology- and non-ideality-agnostic. CMs can mitigate the effects of faulty devices, D2D variability, RTN and line resistance in combination with each other. Although CM method is slightly less effective with high line resistance (see discussion in Supplementary Note 1), in all cases, we observe that the accuracy of individual non-ideal networks largely determines the accuracy of committees. That is consequential because it means that although committees always increase the accuracy, there is still an incentive to optimise the devices and systems that implement these networks—the higher the accuracy of individual networks, the higher the accuracy of the committees.

It is also important to consider whether using larger networks, instead of committees of smaller networks, would yield the same results if the same number of synapses (or memristors) was used in the large network as in the committee of smaller networks. In our previous work we found that the accuracy of networks before disturbance (which we call "starting accuracy") has a huge effect on the robustness to non-idealities—the larger the starting accuracy, the more robust the networks become . One way to achieve higher starting accuracy is to have larger networks, e.g. if we have a network with one hidden layer, we might increase the number of neurons in that hidden layer, which would likely result in higher accuracy after training and thus higher robustness.

Figure  shows a comparison of CMs of memristor-based networks disturbed using faulty devices and D2D variability data from / crossbar, when controlled for the total number of memristors that is required to implement them (line resistance was not taken into account due to long time required to simulate it in large networks). We can observe that committees of two networks, each with 25 hidden neurons, (leftmost data point of the orange curve) achieve $\sim$`<!-- -->`{=html}0.9% higher median accuracy than individual networks with 50 hidden neurons (second data point from the left in the vermilion curve), despite both requiring almost identical total number of memristors. Committees of two networks, each with 100 hidden neurons, (third data point from the left in the orange curve) achieve $\sim$`<!-- -->`{=html}1.1% higher median accuracy than individual networks with 200 hidden neurons (rightmost data point in the vermilion curve), even though both require almost the same total number of memristors. Even larger improvement is gained when committees of four networks, each with 50 hidden neurons, (second data point from the left in the blue curve) are used instead—then the accuracy is improved by $\sim$`<!-- -->`{=html}1.5%, with almost the exact total number of memristors used.

For different non-idealities and even different training schemes of the ANNs, the equivalents of Figure  might be different, but there are a few common characteristics in all of them. In all cases, for a given total number of memristors used, there is an optimal number of networks that should be used in a committee. Additionally, we observe that the more severe a non-ideality is, the more apparent the effectiveness of committees becomes. Finally, sometimes the committees (for a fixed total number of memristors) might achieve lower accuracy than individual networks but only if the networks that they replace are very small and the non-ideality is not very detrimental. If the networks that are being replaced with committees of smaller networks, are sufficiently large, the committees will achieve higher accuracy. An example of that is shown in Supplementary Figure 7 where aVMCO device is minimally affected by the non-idealities and so the advantage of committees becomes apparent only when replacing larger networks.

The reason why committees work in the context of non-ideal implementations and why they work best when they are used to replace large networks might, to some extent, lie in their training. When it comes to training fully connected networks, their accuracy tends to saturate as more parameters are added. Supplementary Figure 4 shows that networks with 50 hidden neurons can be trained to achieve significantly higher accuracy than networks with 25 hidden neurons. However, networks with 200 hidden neurons achieve only slightly higher accuracy than networks with 100 hidden neurons. This also means that networks with 200 hidden neurons will be only slightly more robust to non-idealities than networks with 100 hidden neurons. When such networks are affected by non-idealities, their accuracy drops to similar values but the smaller network can work in a committee with other networks, totalling almost the same number of memristors as the large network, but achieving higher accuracy overall. This is the most likely reason why the committees of smaller networks are effective at dealing with non-idealities, especially when replacing large networks.

In addition to the accuracy improvements, committees can provide flexibility in memristive implementations of neural networks. Digital implementations of ANNs have very predictable behaviour due to the precision of digital logic. Analogue implementations, on the other hand, can vary greatly even if they use the same weights before the mapping onto conductances—that is a result of the stochastic nature of memristors that implement these ANNs. The parallel and modular nature of committee machines makes memristive systems much more flexible. For example, if the verification accuracy of one of the ANNs in a memristor-based CM deteriorates below acceptable levels, its outputs could be disabled to ensure higher accuracy of the rest of the committee.

Importantly, this introduced parallelism comes at almost no extra cost. For a fixed total number of memristors, a committee of smaller networks, compared to a large individual network, would only require a few additional output and bias neurons, and an averaging functionality, which could potentially be implemented in hardware. For example, an ANN with 50 hidden neurons would require 846 neurons in total, while a committee of two ANNs, each with 25 hidden neurons (and thus requiring almost the same total number of memristors), would require 857 neurons in total.

In summary, our simulations employing experimental data from three different types of memristive devices show that committee machines employing ensemble averaging can be used to mitigate the effects of device- and system-level non-idealities in memristor-based neural networks. EA allows to achieve higher inference accuracy in physically implemented neural networks that suffer from faulty devices, device-to-device variability, random telegraph noise, and even line resistance. This method is a universal way to deal with the most common non-idealities and is straightforward to implement during the fabrication stage. Increased modularity of these memristive neural network systems will increase not only their inference accuracy, but also their robustness and flexibility, even without the need to sacrifice area. Although some level of non-idealities in memristors is unavoidable, CM method allows us to deal with these on the system level and is agnostic to a particular technology or, to some degree, type of the non-ideality.

# Methods

## Experiments

/ RRAM 1T1R array consists of NMOS transistors fabricated in a commercial fab (feature size of 2 μm) and // devices. The bottom electrode was deposited by evaporation of 20 nm layer on top of a 2 nm tantalum () adhesive layer; the electrode was patterned by photolitography and a lift-off process. A 5 nm switching layer was deposited by atomic layer deposition using water and tetrakis(dimethylamido)hafnium as precursors at 250 ° C. Sputter-deposited Ta of 50 nm thickness followed by 10 nm was used in a lift‐off process to serve as the top electrode. The filamentary based device consists of a /4nm stoichiometric /20 nm nonstoichiometric /10 nm / stack with a cross-sectional area of $\SI[mode=text]{75}{nm} \times \SI[mode=text]{75}{nm}$, while the non-filamentary-based aVMCO has a cross-sectional area of $\SI[mode=text]{135}{nm} \times \SI[mode=text]{135}{nm}$ and is composed of a /8 nm amorphous-/8 nm anatase / stack. and aVMCO devices were fabricated by imec. The detailed fabrication process parameters can be found in references for /, and aVMCO RRAMs respectively.

The conductance of / devices was modulated by applying SET pulses (500 μs @ 2.5 V and gate voltage increasing from 0.6 V to 1.6 V). After each of the 11 cycles, RESET pulses were applied (5 μs @ 0.9 V increasing to 2.2 V and gate voltage of 5 V). The voltage was being increased linearly throughout the 100 pulses. All electrical tests for and aVMCO devices were done with a Keysight B1500A. The RTN data is extracted by switching the device into 8 uniformly distributed resistance levels between 25 k Ω and 200 k Ω, and 8 nearly uniformly distributed resistance levels between 1 M Ω and 7.5 M Ω with incremental RESET DC sweeps for and aVMCO respectively. RTN measurement is then carried out at each resistance level at a 0.1 V and 3 V read-out for and aVMCO respectively, with a sampling time of 2 ms/point and 10,000 sampling point per resistance level for an RTN measurement period of 20 s.

## Simulations

In this work, feed-forward ANNs with fully connected layers and continuous weights were trained to recognise handwritten digits using the MNIST data base. All 60,000 MNIST training images were used during the training stage; training set consisted of 50,000 images and verification set consisted of 10,000 images. All 10,000 test images were used to evaluate the inference accuracy of ANNs. Networks used 784 input neurons representing pixel intensities of MNIST images of $28 \times 28$ pixel size, as well as one bias neuron. 10 output neurons were used; they represented the ANNs' predictions of 10 handwritten digits. Hidden layers used sigmoid activation function, while the output layer used softmax activation function. Weights were optimised by minimising cross-entropy error function using stochastic gradient descent. Learning rate of 0.01 and patience of 25 epochs were used. 25 networks were trained for each architecture explored by initialising them differently. When numerically optimising ANNs' weightings, optimisation was performed by employing verification set, while the performance was evaluated using the test set. The code was implemented in Python.

Weights were mapped onto pairs of memristors' conductances using proportional mapping scheme—synaptic weights were made proportional to one of the conductances in the pair, while the other was left unelectroformed. The zero weight was interpreted as given—in practise, it would be implemented by not electroforming the device, thus resulting in its negligible conductance. Although aVMCO devices do not have electroforming stage, for consistency we assumed that additional insulating circuit elements could be used to implement the zero weight. Negative weights would be implemented by placing certain memristors in dedicated bit lines of the crossbars whose outputs would be subtracted from the outputs at the corresponding bit lines implementing positive weights. Maximum weights after mapping were optimised separately for each set of network architecture and conductance levels; in each case this was done by excluding a certain proportion, $p_\mathrm{L}$, of weights with largest absolute values. What $p_\mathrm{L}$ values were used for each simulation is summarised in Supplementary Table 1. More details on the mapping procedure can be found in our past work .

All non-idealities, except for line resistance, were simulated by disturbing the individual conductances of memristor-based ANNs. To investigate line resistance, nodal analysis was employed. By setting up simultaneous linear equations using Ohm's law and Kirchhoff's current law, those were solved in sparse matrix representation using Python's library scipy.

After simulating memristor non-idealities, committees of different ANNs were composed. Committees used EA, i.e. the outputs of individual networks in a committee were averaged to produce a single output vector. In EA, the output vectors of individual networks can simply be added together (if the weightings of different networks are the same, as we assume in the main text); the label corresponding to the entry with the highest value would be the prediction of the committee. This addition can be performed either in software, or, if the activation function of the last neuronal layer can be implemented physically, it can be performed by adding corresponding currents produced by the circuitry of this activation function.

In the simulations, neural networks that go into a committee were chosen randomly. This was done to reflect the most convenient strategy when manufacturing such systems—because one does not need to selectively choose the networks, manufactured crossbars can be easily programmed without the need to replace them if they perform poorly when working individually (unless their effect is so detrimental that they have to be ignored which can be made possible with this technique). Besides, devices might change over time, thus these simulations, which show what happens when one does not selectively choose the networks, are valuable to investigate conditions where it is not possible to replace the networks.

In the simulations, 25 base networks were used (each having different set of weights) for each of the architectures. Then all of their weights were mapped onto pairs of conductances using HRS/LRS values extracted from experiments. Finally, to reflect the effect of each of the non-idealities, all networks were disturbed multiple times. In each disturbance iteration, multiple combinations of networks were chosen and their performance as a committee of certain size was evaluated. In total, for most simulations, 10,000 data points were recorded for a committee of every size—these data captured the variations of base networks, their combinations and different disturbance iterations. Only simulations involving line resistance or numerical optimisation of weights had fewer data points for some committee sizes (due to long simulation times).

# Data Availability

The experimental data that support the findings of this study are available from the corresponding author upon reasonable request. Data generated during the simulations are provided as a Source Data file in the Nature Communications paper.

# Author Contributions

A.M. and D.J. conceived the idea and designed the study. A.M., P.F. and Z.C. performed the experimental measurements. D.J. performed the simulations and analysed the experimental and simulation results. C.L. and Q.X. provided the experimental data of the programming of a / 1T1R RRAM array. W.H.N. and M.B. contributed to the understanding of the electrical behaviour of memristor devices. A.M., W.D.Z. and A.J.K. supervised the research. D.J. wrote the initial manuscript. All authors contributed to the discussions of the results and improved the text.

# Competing Interests Statement

The authors declare no competing interests.

# Funding

A.M. acknowledges funding from the Royal Academy of Engineering under the Research Fellowship scheme, A.J.K. acknowledges funding from the Engineering and Physical Sciences Research Council (EP/P013503/1) and the Leverhulme Trust (RPG-2016-135), W.D.Z. acknowledges funding from the Engineering and Physical Sciences Research Council (EP/S000259/1), D.J. acknowledges studentship funding from the Engineering and Physical Sciences Research Council (ref. 2094654).

[^1]: Correspondence and requests for materials should be addressed to A.M. (<firstname.lastname@example.com>) or D.J. (<email@example.com>).


abstract: We propose an efficient protocol for measuring the concurrence of arbitrary two-photon pure entangled state with the help of the photonic Faraday rotation. In the protocol, the concurrence of the photonic entangled state can be conversed into the total success probability for picking up the odd-parity photonic state. For completing the measurement task, we require some auxiliary three-level atoms, which are trapped in the low-quality cavities. Our protocol can be well realized under current experimental conditions. Moreover, under practical imperfect atom state detection and photonic Faraday rotation conditions, our protocol can also work well. Based on these features, our protocol may be useful in current quantum information processing.
address: $^1$College of Mathematics & Physics, Nanjing University of Posts and Telecommunications, Nanjing, 210003, China
  $^2$Key Lab of Broadband Wireless Communication and Sensor Network Technology, Nanjing University of Posts and Telecommunications, Ministry of Education, Nanjing, 210003, China
author: Lan Zhou$^{1,2}$ [^1]
title: Measurement of arbitrary two-photon entanglement state with the photonic Faraday rotation

# Introduction

In the quantum information and computation field, entanglement plays an extremely important role. In almost all the quantum information tasks, such as the quantum teleportation , quantum dense coding , quantum communication , quantum state sharing , and entanglement-based quantum key distribution , the nonlocal parties need the entanglement to setup the quantum channel. Meanwhile, in various quantum computation tasks, such as the linear optics quantum computation , one-way quantum computation , and so on , we also need to create entanglement.

In practical applications, we usually need to know the exact information on the entanglement. In this way, during the past few years, the entanglement quantization has become an important and interesting topic in the quantum information processing. In the early works, both the entanglement witness and Bell inequality have been used to characterize the entanglement . However, they can only disclose the entanglement of some quantum states but fail for other states. In this way, they cannot provide satisfactory results in general. In 1999, White *et al.* proposed a straightforward method for measuring the entanglement based on the complete tomographic reconstruction of the quantum state . However, the reconstruction of a two-qubit state requires to know 15 parameters, which is so complicated in practical operations. So far, the entanglement of formation (EOF), which is firstly proposed by Bennett *et al.* in 1996, has been the most valuable entanglement quantization method . The EOF is often used to quantify the minimal cost to prepare a certain quantum state. It has been shown that the EOF for an arbitrary two-qubit state can be exactly defined by the concurrence (C). For an arbitrary two-qubit state $\rho$, the concurrence can be defined as $$\begin{aligned}
C(\rho)=max\{0,\lambda_{1}-\lambda_{2}-\lambda_{3}-\lambda_{4}\},
\end{aligned}$$ where $\lambda_{i}$ (i=1,2,3,4) are the non-negative eigenvalues in decreasing order of the Hermitian matrix $R=\sqrt{\sqrt{\rho}\tilde{\rho}\sqrt{\rho}}$. $\tilde{\rho}=(\sigma_{y}\otimes\sigma_{y})\rho^{*}(\sigma_{y}\otimes\sigma_{y})$, where $\sigma_{y}$ and $\rho^{*}$ are the usual Pauli operator and the complex conjugate of $\rho$. For a pure state $|\Psi\rangle$, the concurrence can be rewritten as $$\begin{aligned}
C(|\Psi\rangle)=|\langle\Psi^{*}|\sigma_{y}\otimes\sigma_{y}|\Psi\rangle|,
 \sigma_{y}=
 \left[
 \begin{array}{cc}
 0 &-i\\
 i& 0
 \end{array}
 \right].
\end{aligned}$$ where $\sigma_{y}$ is the Pauli matrix of $|\Psi\rangle$. Moreprecisely, for a general two-qubit pure state as $|\Psi\rangle=a_{1}|00\rangle+a_{2}|01\rangle+a_{3}|10\rangle+a_{4}|11\rangle$, where $|a_{0}|^{2}+|a_{1}|^{2}+|a_{2}|^{2}+|a_{3}|^{2}=1$, the concurrence can be simplified as $$\begin{aligned}
C(|\Psi\rangle)=2|a_{1}a_{4}-a_{2}a_{3}|.
\end{aligned}$$

In 2006, Walborn *et al.* experimentally realized the determination of entanglement with a single measurement in linear optics . In their experiment, they successfully measured the concurrence for a partially entangled state $|\varphi\rangle=\alpha|01\rangle+\beta|10\rangle$, whose concurrence can be written as $C=2|\alpha\beta|$. Later, Romero *et al.* proposed an effective way for detecting the concurrence of pure atomic state with the help of the controlled-not (CNOT) gate . Recently, the group of Cao put forward two efficient methods for measuring the concurrence of the two-photon polarization entangled pure or mixed states, with the help of the cross-Kerr nonlinearity .

During the past few year, available techniques have achieved the input-output process relevant to optical cavities with low-quality (Q) factors, such as the microtoroidal resonator (MTR) . It is attractive and applicable to combine the input-output process with low-Q cavities, for if achieved, it can accomplish high-Q quantum tasks with currently available techniques. In 2009, An *et al.* put forward an innovative scheme to implement the quantum information tasks by moderate cavity-atom coupling with low-Q cavities . They have shown that when the photon interacts with an atom trapped in a low-Q cavity, differently polarized photons can make different phase rotation, which is called photonic Faraday rotation. The photonic Faraday rotation only works in low-Q cavities and is insensitive to both cavity decay and atomic spontaneous emission. In 2012, based on the photonic Faraday rotation, the group of Peng proposed two entanglement concentration protocols (ECP) for arbitrary atomic state and photonic states, respectively , which were improved by our group later . In 2008, Lee *et al.* adopted the atoms as the flying qubits to realize the measurement for the concurrence in a cavity quantum electrodynamics (QED) system .

Inspired by the previous works, in the paper, we design a protocol for measuring the concurrence of arbitrary two-photon pure entangled state with the photonic Faraday rotation in a low-Q cavity QED system. We require some auxiliary three-level atoms, which are trapped in the low-Q cavities. We make the photon pulse pass through the low-Q cavity and react with the three-level atom. Taking use of the photonic Faraday rotation, we can converse the concurrence of the photonic state into the total success probability for picking up the odd-parity photonic state, which can be measured directly. Our protocol does not require the complicated operation and can be realized under current imperfect experimental conditions. In this way, our protocol may be useful in current quantum information processing.

# The basic principle of photonic Faraday rotation

The photonic Faraday rotation is the key operation in our protocol. We would introduce the basic principle of the photonic Faraday rotation, before explaining the details of our protocol. As shown in Fig. 1, suppose that a three-level atom is trapped in the one-side low-Q cavity. The states $|g_{L}\rangle$ and $|g_{R}\rangle$ represent the two Zeeman sublevels of its degenerate ground state, and $|e\rangle$ represents its excited state. A single photon pulse with the form of $|\varphi_{in}\rangle=\frac{1}{\sqrt{2}}(|L\rangle+|R\rangle)$ enters the cavity and reacts with the three-level atom, where $|L\rangle$ and $|R\rangle$ represent the left-circularly polarization and right-circularly polarization of the input photon, respectively. When the atom absorbs or emits a $|L\rangle$ ($|R\rangle$) polarized photon, it will cause the transitions $|g_{L}\rangle\leftrightarrow|e\rangle$ ($|g_{R}\rangle\leftrightarrow|e\rangle$).

The Hamiltonian of the whole system can be written as , $$\begin{aligned}
H=H_{0}+\hbar\lambda\sum_{j=L,R}(a^{\dagger}_{j}\sigma_{j-}+a_{j}\sigma_{j+})+H_{R},\label{hamiltonian}
\end{aligned}$$ with $$\begin{aligned}
H_{0}=\sum_{j=L,R}[\frac{\hbar\omega_{0}}{2}\sigma_{jz}+\hbar\omega_{c}a^{\dagger}_{j}a_{j}],\label{h0}
\end{aligned}$$ and $$\begin{aligned}
H_{R}&=&H_{R0}+i\hbar[\int_{-\infty}^{\infty}d\omega\sum_{j=L,R}\alpha(\omega)(b^{\dagger}_{j}(\omega)a_{j}+b_{j}(\omega)a^{\dagger}_{j})\nonumber\\
&+&\int_{-\infty}^{\infty}d\omega\sum_{j=L,R}\bar{\alpha}(\omega)(c^{\dagger}_{j}(\omega)\sigma_{j-}+c_{j}(\omega)\sigma_{j+})].\label{hr}
\end{aligned}$$ Here, $\lambda$ is the atom-field coupling constant. $a^{\dagger}_{j}$ and $a_{j}$ ($j=L, R$) are the creation and annihilation operators of the filed-mode in the cavity, respectively. $\sigma_{L-}$ and $\sigma_{L+}$ ($\sigma_{R-}$ and $\sigma_{R+}$) are the lowering and raising operators of the transition L (R), respectively. $\omega_{c}$, $\omega_{p}$, and $\omega_{0}$ represent the field frequency, photon frequency and atomic frequency, respectively. $H_{R0}$ represents the Hamiltonian of the free reservoirs, and $b_{j}$, $c_{j}$ ($b^{\dagger}_{j}$ and $c^{\dagger}_{j}$) are the annihilation (creation) operators of the reservoirs.

By solving the Langevin equations of motion for cavity and atomic lowering operators analytically, we can obtain a single relation between the input and output single-photon state as $$\begin{aligned}
r(\omega_{p})\equiv\frac{a_{out,j(t)}}{a_{in,j(t)}}=\frac{[i(\omega_{c}-\omega_{p})-\frac{\kappa}{2}][i(\omega_{0}-\omega_{p})+\frac{\gamma}{2}]+\lambda^{2}}
{[i(\omega_{c}-\omega_{p})+\frac{\kappa}{2}][i(\omega_{0}-\omega_{p})+\frac{\gamma}{2}]+\lambda^{2}}.\label{r}
\end{aligned}$$ Here, $\kappa$ and $\gamma$ are the cavity damping rate and atomic decay rate, respectively. If the atom uncouples to the cavity, which makes $\lambda=0$, we can simplify Eq. () as $$\begin{aligned}
r_{0}(\omega_{p})=\frac{i(\omega_{c}-\omega_{p})-\frac{\kappa}{2}}{i(\omega_{c}-\omega_{p})+\frac{\kappa}{2}}.\label{r0}
\end{aligned}$$ Eq. () can be written as a pure phase shift $r_{0}(\omega_{p})=e^{i\phi_{0}}$. On the other hand, in the interaction process, as the photon experiences an extremely weak absorption, we can consider that the output photon only experiences a pure phase shift without any absorption. In this way, with strong $\kappa$, weak $\gamma$ and $g$, Eq. () can be simplified to $r(\omega_{p})\simeq e^{i\phi}$. Therefore, if the photon pulse takes action, the output photon state will convert to $|\varphi_{out}\rangle=r(\omega_{p})|L (R)\rangle\simeq e^{i\phi}|L (R)\rangle$, otherwise, the single-photon would only sense the empty cavity, and the output photon state will convert to $|\varphi_{out}\rangle=r_{0}(\omega_{p})|L (R)\rangle= e^{i\phi_{0}}|L (R)\rangle$.

In this way, for an input single-photon state $|\varphi_{in}\rangle=\frac{1}{\sqrt{2}}(|L\rangle+|R\rangle)$, if the initial atom state is $|g_{L}\rangle$, the output photon state can evolve to $$\begin{aligned}
|\varphi_{out}\rangle_{-}=\frac{1}{\sqrt{2}}(e^{i\phi}|L\rangle+e^{i\phi_{0}}|R\rangle),\label{L}
\end{aligned}$$ while if the initial atom state is $|g_{R}\rangle$, the output photon state will evolve to $$\begin{aligned}
|\varphi_{out}\rangle_{+}=\frac{1}{\sqrt{2}}(e^{i \phi_{0}}|L\rangle+e^{i \phi}|R\rangle).\label{R}
\end{aligned}$$ Based on Eq. () and Eq. (), the angle $\Theta^{-}_{F}=\phi_{0}-\phi$ or $\Theta^{+}_{F}=\phi-\phi_{0}$ is defined as the photonic Faraday rotation.

In Eq. () and Eq. (), it can be found that in a certain case, i.e., $\omega_{0}=\omega_{c}$, $\omega_{p}=\omega_{c}-\frac{\kappa}{2}$, and $g=\frac{\kappa}{2}$, we can obtain $\phi=\pi$ and $\phi_{0}=\frac{\pi}{2}$, so that the relation between the input and output photonic state can be written as $$\begin{aligned}
&&|L\rangle|g_{L}\rangle\rightarrow -|L\rangle|g_{L}\rangle,\qquad |R\rangle|g_{L}\rangle\rightarrow i|R\rangle|g_{L}\rangle,\nonumber\\
&&|L\rangle|g_{R}\rangle\rightarrow i|L\rangle|g_{R}\rangle,\qquad |R\rangle|g_{R}\rangle\rightarrow -|R\rangle|g_{R}\rangle.\label{rule}
\end{aligned}$$

# Detection of the concurrence of arbitrary two-photon entangled state

Now, we begin to introduce our protocol for detecting the concurrence of the photonic entangled state with the help of the photonic Faraday rotation. We suppose two nonlocal parties, Alice and Bob, share two pairs of arbitrary two-photon entangled states with the same form of $$\begin{aligned}
|\phi_{1}\rangle_{a1b1}&=&\alpha|RR\rangle_{a1b1}+\beta|RL\rangle_{a1b1}+\gamma|LR\rangle_{a1b1}+\delta|LL\rangle_{a1b1},\nonumber\\
|\phi_{2}\rangle_{a2b2}&=&\alpha|RR\rangle_{a2b2}+\beta|RL\rangle_{a2b2}+\gamma|LR\rangle_{a2b2}+\delta|LL\rangle_{a2b2},
\end{aligned}$$ where $\alpha$, $\beta$, $\gamma$, and $\delta$ are the entanglement coefficients of the photonic state, and $|\alpha|^{2}+|\beta|^{2}+|\gamma|^{2}+|\delta|^{2}=1$.

In this way, the whole four-photon state can be written as $$\begin{aligned}
&&|\Phi\rangle_{a1a2b1b2}=|\phi_{1}\rangle_{a1b1}\otimes|\phi_{2}\rangle_{a2b2}\nonumber\\
&=&(\alpha^{2}|RRRR\rangle+\alpha\beta|RRRL\rangle+\alpha\gamma|RLRR\rangle+\alpha\delta|RLRL\rangle\nonumber\\
&+&\alpha\beta|RRLR\rangle+\beta^{2}|RRLL\rangle+\beta\gamma|RLLR\rangle+\beta\delta|RLLL\rangle\nonumber\\
&+&\alpha\gamma|LRRR\rangle+\beta\gamma|LRRL\rangle+\gamma^{2}|LLRR\rangle+\gamma\delta|LLRL\rangle\nonumber\\
&+&\alpha\delta|LRLR\rangle+\beta\delta|LRLL\rangle+\gamma\delta|LLLR\rangle+\delta^{2}|LLLL\rangle)_{a1a2b1b2}.\label{whole}
\end{aligned}$$

As shown in Fig. 2, Alice and Bob prepare three three-level atoms, here named $"1"$, $"2"$, and $"3"$. All the three atoms are in the same state as $|\varphi\rangle=\frac{1}{\sqrt{2}}(|g_{L}\rangle+|g_{R}\rangle)$, and trapped in three low-Q cavities, respectively. Each of two parties makes the two photons in his/her hand pass through one low-Q cavity and interact with the atom, successively. Based on Eq. (), we can obtain the relation between the input and output photon-atom state as $$\begin{aligned}
&&|R\rangle|R\rangle(|g_{L}\rangle+|g_{R}\rangle)\rightarrow|R\rangle|R\rangle(-|g_{L}\rangle+|g_{R}\rangle),\nonumber\\
&&|L\rangle|L\rangle(|g_{L}\rangle+|g_{R}\rangle)\rightarrow|L\rangle|L\rangle(|g_{L}\rangle-|g_{R}\rangle),\nonumber\\
&&|R\rangle|L\rangle(|g_{L}\rangle+|g_{R}\rangle)\rightarrow -i|R\rangle|L\rangle(|g_{L}\rangle+|g_{R}\rangle),\nonumber\\
&&|L\rangle|R\rangle(|g_{L}\rangle+|g_{R}\rangle)\rightarrow -i|L\rangle|R\rangle(|g_{L}\rangle+|g_{R}\rangle).\label{rule2}
\end{aligned}$$

It can be found that if the two photons are in the even parity, such as $|RR\rangle$ or $|LL\rangle$, the atomic state will be changed, while if they are in the odd parity, such as $|RL\rangle$ or $|LR\rangle$, the atomic state will keep the same. After the photon-atom interaction, Alice and Bob detect the atomic states. If they select the items which make the atomic states not change, Eq. () will collapse to $$\begin{aligned}
|\Phi_{1}\rangle_{a1a2b1b2}&=&\alpha\delta(|RLRL\rangle_{a1a2b1b2}+|LRLR\rangle_{a1a2b1b2})\nonumber\\
&+&\beta\gamma(|RLLR\rangle_{a1a2b1b2}+|LRRL\rangle_{a1a2b1b2}),\label{select}
\end{aligned}$$ with the success probability of $P_{1}=2|\alpha\delta|^{2}+2|\beta\gamma|^{2}$.

Next, Alice performs the Hadamard (H) operation on the photons in $a1$ and $a2$ modes by making them pass through the quarter wave plate (QWP). The H operation can make $$\begin{aligned}
|R\rangle\rightarrow\frac{1}{\sqrt{2}}(|R\rangle+|L\rangle),\qquad
|L\rangle\rightarrow\frac{1}{\sqrt{2}}(|R\rangle-|L\rangle).
\end{aligned}$$ After that, Eq. () will evolve to $$\begin{aligned}
|\Phi_{2}\rangle_{a1a2b1b2}&=&(\alpha\delta+\beta\gamma)(|RR\rangle-|LL\rangle)_{a1a2}(|RL\rangle+|LR\rangle)_{b1b2}\nonumber\\
&+&(\alpha\delta-\beta\gamma)(|LR\rangle-|RL\rangle)_{a1a2}(|RL\rangle-|LR\rangle)_{b1b2}.\label{QWP}
\end{aligned}$$

Then, Alice makes the two photons in a1 and a2 modes enter another cavity and interact with the atom "3". According to Eq. (), Alice also selects the items, which make the atomic state not change. In this way, Eq. () will collapse to $$\begin{aligned}
|\Phi_{3}\rangle_{a1a2b1b2}=(|LR\rangle-|RL\rangle)_{a1a2}(|RL\rangle-|LR\rangle)_{b1b2},\label{result}
\end{aligned}$$ with the success probability of $P_{2}=\frac{|\alpha\delta-\beta\gamma|^{2}}{2(|\alpha\delta|^{2}+|\beta\gamma|^{2})}$.

Therefore, the total success probability for obtaining the state in Eq. () can be calculated as $$\begin{aligned}
P_{total}=P_{1}P_{2}=|\alpha\delta-\beta\gamma|^{2}=\frac{C^{2}(\phi)}{4}.\label{relation}
\end{aligned}$$ Based on the relationship between the concurrence and the total success probability for obtaining Eq. (), we can obtain the concurrence of the photonic state by detecting the $P_{total}$. Of course, in the practical experiment, in order to measure the $P_{total}$ exactly, we need to repeat the protocol for a large number of times and consume large number of photonic and atomic states.

# Discussion and summary

In the paper, we propose an effective protocol for detecting the concurrence of arbitrary two-photon pure entangled state. In the protocol, we adopt the photonic Faraday rotation to construct the quantum nondemolition measurement for the photonic states. After the photon-atom interaction, by measuring the atomic state in the low-Q cavity and selecting the photonic items which make the atomic state not change, we can distill the photonic states in the odd parity, with the success probability of $P_{total}$. Based on the relationship between $P_{total}$ and the concurrence in Eq. (), we can directly obtain the concurrence of the arbitrary two-photon entangled state by exactly calculating the $P_{total}$. In our protocol, in order to realize the photonic Faraday rotation, the three-level atom encoded in the low-Q cavity is the key element. Under current experimental conditions, $^{87}Rb$ and $^{85}Rb$ atoms encoded in the fiber-based Fabry-Perot cavity have been proved to be good candidate systems. In Ref. , they choose the states of $|F=2\rangle$, $m_{F}=\pm1$ of the $5S_{1/2}$ to be the two ground states $|g_{L}\rangle$ and $|g_{R}\rangle$, respectively. Under this case, the transition frequency between the ground states and the excited state at $\lambda=780 nm$ is $\omega_{0}=\frac{2 \pi c}{\lambda} \approx 2.42 \times 10^{15} Hz$. The cavity length, cavity rate and the finesse are $L=38.6 \mu m$, $\kappa=2\pi \times 53 MHz$ and F=37000, respectively. In the past few years, certain studies on the atom state detection of $^{85}Rb$ atoms coupled to an optical cavity have also been reported. For example, in 2005, Nu$\beta$mann *et al.* have successfully controlled and adjusted the individual ultracold $^{85}Rb$ atoms coupled to a high-finesse optical cavity . In 2007, Fortier *et al.* realized the deterministic loading of single $^{85}Rb$ atoms in a cavity by incorporating a deterministically loaded atom conveyor . Based on the early experimental works, our protocol can be well realized under current experimental conditions.

In the above description, our protocol is operated under the ideal conditions that the atom detection efficiency $\eta_{a}=100\%$ and the photonic Faraday rotation angle $\Theta^{+}_{F}=\phi-\phi_{0}=\frac{\pi}{2}$. Actually, in practical experiment, both the imperfect detection of the atom state and the imperfect photonic Faraday rotation angle will cause some influence on the protocol.

In our protocol, for completing the detection task, we need to detect the atom state for three times. In experiment, the atom state detection efficiency $\eta_{a}<100\%$. Considering this imperfect detection, the description of $P_{total}$ can be revised as $$\begin{aligned}
P'_{total}=\eta^{3}_{a}|\alpha\delta-\beta\gamma|^{2}=\eta^{3}_{a}\frac{C^{2}(\phi)}{4}.\label{relation1}
\end{aligned}$$ In this way, in practical experiment, we need to detect $\eta_{a}$ first. In the past few years, certain studies on the atom state detection of $^{85}Rb$ atoms coupled to an optical cavity have been reported. For example, Heine *et al.* reported their research result on the single atom detection. They have achieved $\eta_{a}= 66\%$ in the experiment . Moreover, they have shown that with some improvement, the single atom detection efficiency can achieve $\eta_{a}> 95\%$ in theory.

On the other hand, in practical experiment, it is quite difficult to exactly control $\Theta^{+}_{F}=\pi/2$ exactly. Therefore, it is quite possible that $\Theta^{+}_{F}=\frac{\pi}{2}+\sigma$, where $\sigma$ is a small quantity. Under this case, Eq. () can be modified as $$\begin{aligned}
&&|R\rangle|R\rangle(|g_{L}\rangle+|g_{R}\rangle)\rightarrow|R\rangle|R\rangle e^{2i\phi_{0}}(|g_{L}\rangle-e^{2i\sigma}|g_{R}\rangle),\nonumber\\
&&|L\rangle|L\rangle(|g_{L}\rangle+|g_{R}\rangle)\rightarrow|L\rangle|L\rangle e^{2i\phi_{0}}(-e^{2i\sigma}|g_{L}\rangle+|g_{R}\rangle),\nonumber\\
&&|R\rangle|L\rangle(|g_{L}\rangle+|g_{R}\rangle)\rightarrow |R\rangle|L\rangle e^{i(\phi+\phi_{0})}(|g_{L}\rangle+|g_{R}\rangle),\nonumber\\
&&|L\rangle|R\rangle(|g_{L}\rangle+|g_{R}\rangle)\rightarrow |L\rangle|R\rangle e^{i(\phi+\phi_{0})}(|g_{L}\rangle+|g_{R}\rangle).\label{rule4}
\end{aligned}$$

It can be found that if the two input photons in the odd parity as $|R\rangle|L\rangle$ and $|L\rangle|R\rangle$, the atomic state will also not change. However, if the two input photons are in the even parity as $|R\rangle|R\rangle$ or $|L\rangle|L\rangle$, the atomic state will change to $|g_{L}\rangle-e^{2i\sigma}|g_{R}\rangle$ or $|g_{R}\rangle-e^{2i\sigma}|g_{L}\rangle$. This case may also contribute to the $\frac{1}{\sqrt{2}}(|g_{L}\rangle+|g_{R}\rangle)$ with some probability and cause the detection error. Therefore, in each parity check process, we can calculate the error probability as $$\begin{aligned}
P_{e}=|\frac{1}{\sqrt{2}}(|g_{L}\rangle+|g_{R}\rangle)\frac{1}{\sqrt{2}}(-e^{2i\sigma}|g_{L}\rangle+|g_{R}\rangle)|^{2}
=\frac{|-e^{i2\sigma}+1|^{2}}{4}.
\end{aligned}$$ In this way, in the practical experiment, the detected success probability in each parity check process can be modified as $$\begin{aligned}
P'_{1}&=&P_{1}+(1-P_{1})\frac{|-e^{i2\sigma}+1|^{2}}{4},\nonumber\\
P'_{2}&=&P_{2}+(1-P_{2})\frac{|-e^{i2\sigma}+1|^{2}}{4}.\label{PP}
\end{aligned}$$

Based on Eq. (), if the value of $\sigma$ is known, we can easily calculate exact value of $P_{1}$ and $P_{2}$, and calculate the exact value of $P_{total}$. Therefore, under this imperfect photonic Faraday rotation condition, we can also obtain the concurrence of arbitrary photonic entanglement state.

In summary, in the paper, we put forward an efficient protocol for detecting the concurrence of arbitrary two-photon entangled state. In the protocol, we adopt the photonic Faraday rotation to construct the quantum nondemolition measurement for the photonic state and the concurrence can be conversed into the total success probability for picking up the odd-parity photonic state. For completing the detection task, we need to consume large number of photonic states and auxiliary three-level atoms, each of which is trapped in a low-Q cavity. Comparing with other detection protocol, we do not require the sophisticated CNOT gate or single-photon detector, and our protocol is feasible under current experimental technique. Moreover, under imperfect atom detection and photonic Faraday rotation angle, our protocol can also be well realized. All the features make our protocol useful in current quantum information processing.

# Acknowledgements

This work is supported by the National Natural Science Foundation of China under Grant Nos. 11104159 and 11347110, the open research funds of Key Lab of Broadband Wireless Communication and Sensor Network Technology, Nanjing University of Posts and Telecommunications, Ministry of Education (No. NYKL201303), and the Priority Academic Program Development of Jiangsu Higher Education Institutions.

[^1]: Email address: firstname.lastname@example.com