In-sensor reservoir computing for language learning via two-dimensional memristors

See allHide authors and affiliations

Science Advances  14 May 2021:
Vol. 7, no. 20, eabg1455
DOI: 10.1126/sciadv.abg1455


The dynamic processing of optoelectronic signals carrying temporal and sequential information is critical to various machine learning applications including language processing and computer vision. Despite extensive efforts to emulate the visual cortex of human brain, large energy/time overhead and extra hardware costs are incurred by the physically separated sensing, memory, and processing units. The challenge is further intensified by the tedious training of conventional recurrent neural networks for edge deployment. Here, we report in-sensor reservoir computing for language learning. High dimensionality, nonlinearity, and fading memory for the in-sensor reservoir were achieved via two-dimensional memristors based on tin sulfide (SnS), uniquely having dual-type defect states associated with Sn and S vacancies. Our in-sensor reservoir computing demonstrates an accuracy of 91% to classify short sentences of language, thus shedding light on a low training cost and the real-time solution for processing temporal and sequential signals for machine learning applications at the edge.


The massive amount of data produced and transmitted by the Internet of Things (IoT) requires new insight into real-time information processing by edge computing devices based on novel materials and architectures (1). Proactively interpreting and learning with temporal and sequential information represent key tasks for edge computing devices (2). However, current edge computing systems mostly rely on physically separated sensors and digital processing units, leading to high rate of energy consumption and long-time latencies when sequentially digitizing the analog pixel signals (39). The direct processing of time-varying optical data accounting for more than 80% of the collected information (10) or the perceptions of humans in a bio-plausible fashion would provide a breakthrough by reducing the communication and computation loads of edge computing devices that operate on the IoT.

While recurrent neural networks (RNNs) are highly capable of processing time-series data and various dynamic sequential events (11, 12), the high training complexity in RNNs limits their practical use with regard to edge computing on the IoT (2). Among various frameworks of RNNs, reservoir computing (RC) has demonstrated substantial reductions of the computational cost of learning, offering a promising solution by which to develop edge devices for temporal pattern classification, prediction, and generation (2). In RC, a dynamic reservoir is used to map complex inputs nonlinearly (e.g., spatiotemporal patterns) into high-dimensional states, which can be further augmented by virtual nodes, allowing a simple and fast training of readout weights at a low computation cost.

Thus far, RC systems have been physically implemented on conventional digital platforms and previously unidentified hardware dynamic systems powered by different physical mechanisms (e.g., electronic, photonic, spintronic, mechanical, and biological RC implementations) (6, 9, 1318). For example, RC systems have been built on memristors with a simple structure, high density, good energy efficiency, and three-dimensional (3D) stackability (9). Memristors have demonstrated the ability to mimic the leaky integrate-and-fire operations of neurons in a manner that is more energy and area efficient than digital alternatives, as reported by Du et al., Moon et al., and Midya et al. (6, 8, 9). Conventional memristors mostly rely on redox reactions and the migration of ions and cannot directly respond to optical stimuli. Creating RC systems with high computing efficiency and direct responses to optical inputs without extra sensors/processors remains a challenge. Accordingly, memristors based on novel nanomaterials or hybrid materials (1931) that offer different degrees of plasticity by means of either electrical or optical signals have been reported. However, the realization of an RC system with high computing efficiency enabled by in-memristor computing and direct responses to optical inputs without extra sensors/processors with a simple device structure remains a challenge.

In this study, we demonstrate optoelectronic RC for language learning with dynamic memristors built on a two-terminal tin sulfide (SnS) device structure. The synergy of the charge trap/detrap dynamics and the photogating effects in the atomically thin material used in this study enables high-performance capabilities and versatile memristive behaviors with dual-mode operation (i.e., driven by electrical and optical stimuli), as well as good nonlinearity and fading memory. These memristors constitute an optoelectronic reservoir by responding to sequential electrical and broadband optical stimuli. Mapping complex temporal optoelectronic inputs into high-dimensional reservoir states, the optoelectronic RC described here demonstrates an accuracy of 91% in classifying practical Korean sentences with small natural errors. The low training cost and real-time processing of spatiotemporal signals for optoelectrical stimuli pave the way for efficient edge machine learning.


SnS memristor for optoelectronic RC

Optoelectronic RC for language learning is schematically illustrated in Fig. 1A, where optical stimuli representing a Korean sentence “Embedded Image” (“Let’s buy” in English) was directly used as input into a signal processing system without dedicated image sensors or associated analog-to-digital data conversion. The absence of extra optical sensors and data conversion, reducing the energy and time requirements considerably, represents the major benefit of the optoelectronic RC method beyond traditional RC (fig. S1). This faithfully resembles the biological neural system of photoreceptors in the retina (32). An RNN is embodied as complex connections between neurons (magenta circles), as shown in Fig. 1A, where the connections are not trained in the RC system. Instead, we train the connections of readout weights (colored arrows denoted by θi in Fig. 1A) linking the high-dimensional reservoir states and output neurons representing different sentences under the framework of supervised learning.

Fig. 1 Brain dynamics and spatiotemporal information processing based on in-sensor RC.

(A) Schematic of the cognitive task implemented on a biological RC system. Language learning is carried out by the visual cortex, which can perform time-series computations for sequential inputs. (B) Transport behaviors reflecting the charge trap/detrap dynamics in SnS with an optical microscopy image of the device (inset with a scale bar of 2 μm). The first and final cycles are green and red colors, respectively, and the electrical (C) and optical (D) pulse switching characteristics. Electrical pulses (4.5 V and 20 ms) with an interval of 10 ms were used in (C). Optical pulses with a wavelength of 725 nm, a power of 43 mW, and a width of 3 s were used in (D). The read voltage was 0.5 V. (E) Normalized photocurrent (PC) under continuous optical stimuli with 455, 638, 725, and 811 nm. (F) Acceptor states (Ea) are occupied by electrons in p-type SnS with the Fermi level (Ef) close to the valence band in conventional transport. (G) With a Vd exceeding a threshold voltage (Vth), the electrons trapped at acceptor states are recombined with holes, decreasing the channel current. (H) Under light illumination, electrons are excited and trapped in the donor states created by S atomic vacancies, producing more holes in the valence band and leading to greater conductivity (photogating effect).

The key element of optoelectronic RC is its use of a dynamic memristor with dual-mode operations and fading memory with a 2D material, SnS (for which the Raman spectrum and transport curve are shown in fig. S2). Nonlinear fading memory with depression and facilitation features conductivity that can be modulated by electrical and optical stimuli, respectively, in the SnS (dual mode) (Fig. 1, B to E). This roots on the p-type SnS that has donor and acceptor states in its bandgap (i.e., gap states) originating from the atomic vacancies of Sn (acceptor) and S (donor) (33, 34). The schematic band diagram in Fig. 1F shows the equilibrium state of the p-type SnS for transport with immobile acceptor states occupied by electrons.

The decreasing current upon continuous current-voltage sweeps in Fig. 1 (B and C) and fig. S3 is unique among various 2D materials (fig. S4). The depression of conductivity can be explained by the decreased number of hole carriers (majority carriers) in the valence band during the transport. A large drain voltage bias (Vd in the range of 4 to 5 V) provides enough energy to the electrons trapped at the acceptor states so that they can recombine with holes in the valence band, which decreases the number of hole carriers and thus the current (Fig. 1G) in the p-type semiconductor (SnS). The responses of the dynamic memristor to electrical pulses are shown in Fig. 1C, where voltage pulses with an amplitude of 4.5 V and a width of 20 ms were used to generate dynamic states in RC. The current level is saturated after 0.5 s, as shown in Fig. 1C, revealing the saturation of the role of acceptor states to the transport. On the other hand, typical photogating occurs in donor states under light illumination. More holes are generated by newly excited electrons and are occupying the donor states as stimulated by light (Fig. 1H).

Dynamic memristor states in RC can be generated by optical pulses, as shown in Fig. 1D. A periodic pulse train with an illumination power of 43 mW and an interval of 3 s (wavelength of 725 nm) produces conductance changes that can be used to realize high-dimensional reservoir states in RC. A read voltage of 0.5 V was used to measure the currents induced by optical stimuli, as shown in Fig. 1D, which is modulated by the photogating effect with a short characteristic time of 3 s. The two different trends shown in Fig. 1 (C, depression, and D, facilitation) reflect the rich charge trapping/detrapping dynamics in 2D SnS with a moderate carrier density of ~1012 cm−1. We note that in other 2D systems apart from certain 2D heterostructures or hybrid materials systems (3545), either facilitation or depression dominates the transport, limiting the complexity and multiple-mode operation of optoelectronic RC. Moreover, wide ranges of wavelengths (Fig. 1E and fig. S5) and incident power levels (fig. S6) imply that our optoelectronic RC operates with broadband optoelectronic inputs for various applications.

Spatiotemporal signal processing in a circuit based on SnS memristors

An integrated memristor circuit based on 2D SnS was fabricated to demonstrate the concept of optoelectronic RC (Fig. 2, A and B). Spatiotemporal optoelectronic inputs are applied to the memristors in the array, as schematically illustrated by the pulses (electrical spikes) and discrete optical beam trains (optical spikes) in Fig. 2A. Such sequential optoelectronic inputs can generate numerous (high-dimensional and dual-mode) reservoir states of RC, which are based on the electrical and optical responses of the dynamic memristors, as shown in Fig. 1. The atomic force microscopy (AFM) image in Fig. 2B shows the topology of a memristor RC.

Fig. 2 Dynamic memristor circuit and corresponding responses to optical and electrical stimuli.

(A) Schematic of a multifunctional memristor array stimulated by various electrical and optical inputs. (B) An AFM image and line profile of a device array used in this study. Scale bar, 2 μm. (C) Experimental read-current responses of a memristor by several electrical input signals, (00100), (01001), (01010), (11101), (01110), and (11111). The amplitude and width of the read pulses are correspondingly 1 V and 25 ms. (D) Experimental read-current responses of a memristor by several optical input signals (725 nm and 42 mW) with corresponding width and intervals of 5 and 3 s. The read voltage for the optical pulses was 0.5 V.

Modulation of our dynamic memristor, as shown in Fig. 2C, was achieved upon the reception of six input signals: (00100), (01001), (01010), (11111), (11101), and (01110). The response of the device originates from the combined effects of electrical stimulation and fading memory in the SnS-based memristor. The pulse amplitude and width (4 V and 50 ms) representing the input signal “1” were chosen to reflect the characteristic time of the fading memory (100 ms), which helps to generate the distinct states of the memristor shown in Fig. 2C. Starting with a similar current value, the six inputs, each consisting of five electrical pulses, yield six different final current amplitudes. A decrease of the current occurs upon presenting “1” (due to the electrons being detrapped from acceptor states) while the signal “0” tends to recover the conductance (due to the electrons being trapped to acceptor states), as shown in Fig. 1 (F to H). Therefore, for the electrical inputs, complex memristor states (i.e., reservoir states) can be constructed by signals with different combinations of “0” and “1” with a time interval shorter than 100 ms. We note that this is the first demonstration of RC with devices based on 2D materials.

The six optical inputs and corresponding memristor states are presented in Fig. 2D. Following the optical pulses, an electric bias of 0.5 V was used to record the resultant memristor conductance (currents). The six states, corresponding to six different inputs, are clearly distinguishable, which is a critical property to realize optoelectronic RC. We note that similar photoconductance in 2D semiconductors [e.g., molybdenum disulfides (MoS2)] with high responsivity has also been reported. However, compared to those 2D semiconductors, 2D SnS exhibits better fading memory behavior and is thus able to generate more distinguishable reservoir states based on its opposite and nonlinear responses to electrical and optical stimuli (Fig. 1, C and D, and fig. S4).

Optoelectronic RC for the learning of the Korean language

The integrated memristors were connected to a digital readout layer implemented in software for temporal sequence classification. The sequences consist of the signals representing five complicated consonants and another five vowels of the Korean alphabet, as shown in Fig. 3A. To explain how the system works, a Korean consonant “Embedded Image” (also similar to the capital English alphabet “E” in appearance) was chosen as an example, as shown in Fig. 3A. The consonant is first divided into five rows, or sequences, as shown in the second panel of Fig. 3A. Then, each sequence is converted to a train of temporal optoelectronic pulses; dark green pixels, which constitute the pattern of the consonant, correspond to the signal “1” (high voltage or optical pulse), while light green pixels of the remaining vacant region of the image only receive read voltages (1 V for 25 ms), as shown in the third panel of Fig. 3A. The signals of the five rows are applied to the five corresponding integrated memristors. The corresponding conductance states (high-dimensional states of the RC system) are schematically illustrated by the orange balls in the fourth panel of Fig. 3A.

Fig. 3 In situ training of a memristor array with optoelectronic inputs for language learning.

(A) Schematic of the operation of optoelectronic RC based on 2D SnS memristors for classifying consonants and vowels in the Korean alphabet. Temporal sequences of pulses were used to stimulate the five memristors used with the optoelectronic RC method. (B) and (C) are the weights of readout layers after 100 epochs of electrical and optical stimuli. (D) The distribution of the current responses of the memristor array used in this work, consisting of RC neural current responses to all inputs involved in (A). (E) The evolution of the classification accuracy rates using standard batch gradient descent within 100 epochs of in situ training for electrical (green) and optical (blue) stimuli.

The post-training weights for recognizing the 10 consonants and vowels in Fig. 3A are shown in the color maps in Fig. 3B (for electrical stimuli) and Fig. 3C (for optical stimuli). With five memristors (rows) and six temporal signals (sequences including the initial conductance), there are 30 effective reservoir nodes that serve as the inputs to the readout. The colors of the ith row, consisting of the 31 weights, including the bias weight, represent the synaptic connections of the ith pattern in the supervised learning. The evolution of the weights is provided in the Supplementary Materials (animated GIF images 1 and 2).

The experimental distribution of individual memristor states (or current levels in our SnS-based memristors) is shown in Fig. 3D. These states are measured after receiving different pulses that are used to represent the 10 input patterns in Fig. 3A. The variation of the final memristor states could be explained by the impact of defects on the transport of SnS, as is widely reported in numerous 2D materials. Optoelectronic RC enables simple and fast training of readout weights at a low computation cost, achieving high accuracy in classifying the 10 temporal inputs (100% in 100 epochs), as shown in Fig. 3E. The losses during the learning of classification of the 10-class temporal inputs with the experimental reservoir states are shown in fig. S7. The reservoir outputs and associated probability of readout neurons, taking the first letter as an example, are summarized in fig. S8.

Inference of Korean sentences via optoelectronic RC

Optoelectronic RC based on 2D SnS memristors has been further extended to learn Korean sentences, as shown in Fig. 4A: “Embedded Image” (Let’s go), “Embedded Image”(Get out), “Embedded Image” (Let’s buy), “Embedded Image” (Let’s ride), and “Embedded Image” (Kick). For each sentence, a noise-free image was prepared for training (Fig. 4A), and multiple images with random noises were used for inference (fig. S9). The image for a sentence is split into five rows. Each of them consists of 13 electric pulses that were sequentially applied to a memristor, which is translated to the high-dimensional states of the optoelectronic RC system. Example responses by the five memristors to electrical inputs are shown in fig. S10.

Fig. 4 Recognition of sentences for language learning.

(A) Images of the five sentences used here for RC training. (B) and (C) are correspondingly the initial and final weights of the readout layer before and after the 100-epoch training. The evolution of (D) the classification accuracy rates and (E) the losses during the 100 epochs of the batch gradient descent training process. (F) Confusion matrix for classifying the five sentences of the test set. (G) The states of the reservoir neurons are experimentally measured when the second sentence is presented. (H) Associated probability of readout neurons.

The initial and final weights (after 100 training epochs) are shown in Fig. 4 (B and C, respectively). The y axis indicates that the associated five sentences (patterns) and the 71 data points along the x axis (5 × 14 and the bias) correspond to the dimensionality of the reservoir states. The evolution of the weights (readout map) is shown in the Supplementary Materials (animated GIF image 3). As the epoch number during the training process increases, the classification accuracy improves while the cross-entropy loss decreases, as shown correspondingly in Fig. 4 (D and E) with electrical bias as stimuli. The accuracy in classifying test images with random noise (fig. S9) is as high as 91% for the practical Korean sentences used here. The accuracy is smaller (91%) in Fig. 4D because the patterns (the short Korean sentences) in Fig. 4D are much more complex compared with those used for classification in Fig. 3E. Moreover, for the short Korean sentences of Fig. 4A, intentional background noise (shown in Fig. S9) was introduced, which corresponds to the classification accuracy in Fig. 4D. The inference samples in Fig. S9 were chosen to be different from those used to train the network (shown in Fig. 4A); thus, the accuracy is lowered in Fig. 4D compared with that shown in Fig. 3E.

A confusion matrix showing the classification of the five sentences is presented in Fig. 4F. Nearly all of the sentences were correctly classified by our optoelectronic RC method. We note that the first and third sentences exhibit weak confusion, but recognition overall is not disturbed by the slightly deviating performance. As an example, the outputs of reservoir neurons, or the reservoir states, for the second sentence “Embedded Image” and the probability of the readout neurons (indexed following the five sentences in Fig. 4A) after the training are shown in Fig. 4 (G and H, respectively).

The robustness of our optoelectronic RC approach is demonstrated in Fig. 5. To account for the stochasticity of the neurons, we model the neuron output currents with Gaussian distributions of varying standard deviations (SDs) (σ ranging from 0.1 to 0.6 nA) (Fig. 5A and fig. S11) and simulated the classification accuracy. The first sentence in Fig. 4A, “Embedded Image,” is taken as an example in Fig. 5A. Three commonly used classification methods that can implement the readout map were compared. Each method is applied to the six sets of RC neural outputs with different standard deviations shown in Fig. 5B. Language learning via the proposed optoelectronic RC method exhibits high accuracy rates even with the noisy reservoir node outputs; the accuracy levels of all classification methods exceed 85% with SDs up to σ = 0.6 nA for the different models. Accordingly, the high-dimensional states and the nonlinear evolution of our optoelectronic RC method based on 2D SnS enable robust learning of the Korean language.

Fig. 5 Impact of RC neural stochasticity on the accuracy of classifying the sentences.

(A) SD-dependent probability density function of the RC neural outputs. For each input, we sampled 100 RC neural outputs according to the modeled distributions. The illustrated distributions correspond to the RC neural outputs of the first input sentence, “Embedded Image.” (B) SD-dependent classification accuracy. Three representative supervised learning models that can implement the readout functions were used for evaluation.


The unique electrical and optical responses of 2D SnS, originating from its rich defect states with both Sn and S atomic vacancies, have been successfully adopted for the novel in-sensor RC for language learning with dual-mode operation. The unique and opposite trends of the electrical and optical responses of integrated SnS-based memristors effectively lead to the high-dimensional states of optoelectronic RC with complicated spatiotemporal input signals. As a proof of concept, we achieved an accuracy of 91% during the classification of five practical Korean sentences each containing intentional noise.

Our finding overcomes the hardware bottleneck associated with physically separated sensors and processors, where analog-to-digital data conversion incurs large energy consumption and latency penalties in conventional sensing-computing systems. In addition, RC in this case greatly reduces the learning complexity. This energy-efficient method enables efficient machine learning applications with temporal inputs at the edge, an advance in strong demand in the era of the IoT. Compared with biological neurons of different/specialized sensing modes, our dual-mode processing could be considered as a breakthrough for efficient machine learning and neuromorphic computing.


Device fabrication details

SnS flakes were exfoliated from the original crystal and transferred onto a silicon wafer substrate with 300 nm of SiO2 covered by dry oxidation method. Spin coating with poly(methylmethacrylate) 950 A4 was then carried out at a spin speed of 500 rpm for the first 5 s and of 3000 rpm for the following 60 s. The wafer was subsequently baked at 120°C on a commercial hot plate for 2 min. Exposure of the electrode pattern was carried out by electron beam lithography followed by a standard developing process. Last, Cr/Au 5/100-nm deposition was done using an electron beam evaporator.

Electrical/optical characteristics

Electrical characterization was conducted with a Keithley 4200 semiconductor parameter analyzer and a Cascade probe station. For single-device measurements, the pulse condition is 4.5 V/20 ms. The read voltage is 1 V. The training of reservoir states is based on 11 different inputs relative to the five consonants and five vowels used in this work. For the training of the memristor array, the pulse condition is 4 V/50 ms and the read pulse condition is 1 V/25 ms. Four laser line wavelengths (455, 638, 725, and 811 nm) were used for testing.


Softmax regression was used to fit the weights of the readout layer. The categorical cross-entropy loss is minimized by batch gradient descent using the RMSprop (learning ratio = 0.01) optimizer. The accuracies of the SD-dependent sentence classification shown in Fig. 5B were obtained as follows. The amounts of the current flowing through five memristors in the reservoir at the final time step were used as the inputs to the readout layer. Supervised learning models like single-layer perceptron, support vector machine, and logistic regression were used for the learning of the layer. For the single-layer perceptron, Softmax was used as the activation function. The categorical cross-entropy loss was minimized by a mini-batch (the batch size is 16) gradient descent using the Adam optimizer (learning rate = 0.001). For the support vector machine, the kernel option was chosen to be linear for linear classification. Regularization parameter c was used, whose value was optimized by grid search. For the logistic regression, regularization parameters elasticnet and c were used with grid search for fine-tuning.


Supplementary material for this article is available at

This is an open-access article distributed under the terms of the Creative Commons Attribution-NonCommercial license, which permits use, distribution, and reproduction in any medium, so long as the resultant use is not for commercial advantage and provided the original work is properly cited.


Acknowledgments: This work was supported by the Samsung Research Funding and Incubation Center of Samsung Electronics, under project no. SRFC-MA1701-01. Funding: L.S. appreciates the support from the Beijing Institute of Technology Research Fund Program for Young Scholars and National Research Foundation of Korea, funded by the Ministry of Science and ICT under grant no. NRF-2017H1D3A1A01013759. Z.W. was supported in part by the startup package EEE-20200713 of the University of Hong Kong. B.-S.K. was supported in part by NRF grant (2019R1A2C1011155) and IITP grant (2019-0-00421) funded by MSIT. Author contributions: All authors participated in the scientific discussion. L.S. and H.Y. conceived the concept of optoelectronic RC. L.S. fabricated the devices and device arrays and characterized the devices. Z.W. simulated the RC systems. Y.K., B.J., and B.-S.K. simulated the SD-dependent accuracies. L.S., J.J., and S.Z. carried out the AFM measurements. S.L. helped in the device fabrication. W.J.Y. attended the discussion. L.S. and H.Y. wrote the manuscript and all authors participated in the revision of the manuscript. Competing interests: The authors declare that they have no competing interests. Data and materials availability: All data needed to evaluate the conclusions in the paper are present in the paper and/or the Supplementary Materials. Additional data related to this paper may be requested from the authors.

Stay Connected to Science Advances

Navigate This Article