An artificial olfactory inference system based on memristive devices

Due to the complexity of real environments, it is hard to detect toxic and harmful gases by sensors. To address such an issue, an artificial olfactory sys-tem is promoted, emulating the function of the human nose by means of gas sensors and an inference system. In this work, an artificial olfactory inference system based on memristive devices is developed to classify four gases (ethanol, methane, ethylene, and carbon monoxide) with 10 different concentrations. First, the spike trains converted from signals of the sensor array are inputted to a reservoir computing (RC) system based on volatile memristive devices, which extracts spatiotemporal features; then the features are processed by a classifier based on nonvolatile memristive devices; the output of the classifier indicates the classification result. Moreover, to reduce the device number and the power consumption, three strategies are applied to reduce the extracted features from the RC system. Eventually, the olfactory inference system successfully identifies the gases with a high accuracy of 95%.


| INTRODUCTION
An olfactory system enables living beings to be aware of their environments, of possible dangers, and to identify and classify foods 1 ; the system consists of thousands of different types of olfactory receptors and a classifier (i.e., a neural network). Stimulated by specific odorant molecules, the receptors generate spikes and the neural network infers odors by analyzing these spikes. 2 After learning and training, the olfactory system can remember different signals caused by different odorant molecules, which endows living beings with an ability to recognize odors. 3 Considering the memory-driven computation in biological neural networks, an artificial olfactory system integrates gas sensors and a compute-in-memory system, which enhances the power efficiency. [4][5][6] To emulate the functions of a biological olfactory system, artificial olfactory systems implemented by sensor arrays and inference systems, [7][8][9] have been successfully applied in many areas, for example, food and beverage industry, agriculture and forestry, medicine and healthcare, indoor and outdoor air-quality monitoring. 1,10 However, there is still a big gap between an artificial olfactory system and a biological one, such as imperfect classification precision, high power consumption, and low integration density. 10,11 Artificial olfactory systems are improved in terms of sensors and inference systems. As for sensors, sensor arrays with developed materials were successfully implemented to detect different gases under various conditions. 3,[12][13][14][15][16] And the static features of gas sensors (e.g., sensing response) in a sensor array are widely used to train inference systems based on a machine learning model. 17 These models worked well in some primitive problems, for example, classifying a specific gas with a fixed concentration. 11,15 However, real environments are much more complex, consisting of multiple gases with unpredictable concentrations, therefore, a simple algorithm based on the basic static features of gas sensors does not work. 10 To improve the classification precision, more algorithms in artificial neural networks (ANNs) were proposed. For instance, by using a spiking neural network (SNN), the temporal information of sensors was encoded and processed by spikes; such a case is more similar to that of the human brain. [18][19][20] As a result, the neural network rapidly learned gases online and was robust to noises. 21 Moreover, neuromorphic computing architectures based on SNN integrates sensors, computing cores and memories on one chip, processing sensing data in real-time with high power efficiency. 5,[22][23][24] However, SNNs are incompatible with current computing architecture and need specific circuits. [25][26][27] By using convolution neural networks (CNNs) and recurrent neural networks (RNNs), features of gases were successfully extracted by CNNs and recognized by RNNs with a very short response time. 28 However, CNNs and RNNs usually consume a large amount of computing power.
A reservoir computing (RC) system offers efficient temporal processing of RNNs with low training costs. 29,30 Outputs of the RC system are high dimensional features extracted nonlinearly from temporal data, then the outputs are used as the input of a neural network for the classification task; it is much easier to train a machine learning model by using the output of the RC system than using original data. 31,32 Memristive devices are advantageous in parallel computing, capability of high-density integration, and ability to compute-in-memory. 24,[33][34][35] Many systems based on memristive devices were designed to carry out different tasks by connecting with different types of sensors, such as vision sensing, 4,36 touch sensing, 22,23 and sound sensing. 37 Moreover, RC systems and neural networks were also realized with memristive devices. 33 For instance, an RC system based on volatile memristive devices was successfully used in image and voice recognition. 31,38,39 The conductance of the volatile memristive device was changed nonlinearly under applied pulses and recovered to the initial state spontaneously, which is similar to a reservoir. A single memristive device can replace many virtual nodes in a conventional RC system, enhancing the power efficiency and operating speed. 32,40 Similarly, by using the RC system based on memristive devices, it is possible to extract features of different gases from the responses of gas sensors easily.
ANNs for classification can be implemented by nonvolatile memristive devices. Compared with volatile memristive devices, nonvolatile ones maintain their conductance without the electrical bias; therefore, they are regarded as attractive candidates for artificial synapses. 41 Noteworthily, the matrix multiplication operation is performed in a memristive synaptic array, which stores massive synaptic weights. Therefore, neural networks based on memristive devices realize the in-memory computing, showing similarity to biological neural networks. Many memristive arrays were used in CNNs 20,42,43 and RNNs, 44 offering parallel computing ability to accelerate the time-consuming matrix multiplication operation in CNNs and RNNs.
In this work, an artificial olfactory inference system is implemented based on memristive devices to classify gasses with different concentrations. Gas samples in a dataset are first encoded to spike trains, which are inputted into an inference system comprising of an RC system and a classifier. The RC system, constructed by volatile memristive devices of W/WO 3 /PEDOT:PSS/Pt, extracts features from responses of the gas sensors, and the outputs are the conductance of the memristive devices. To reduce the complexity of the olfactory inference system, three strategies are applied to simplify the extracted features based on spatial, temporal and spatiotemporal dimensions. Finally, the classifier, a three-layer neural network using nonvolatile memristive devices of Pd/W/ WO 3 /Pd, processes extracted features and shows the classification results.

| RESULTS AND DISCUSSION
The responses of the gas sensor array to four different gases (ethanol, methane, ethylene, and carbon monoxide) with 10 different concentrations were obtained from the dataset "Twin gas sensor arrays Data Set". 15 This dataset was collected from five replicates of an 8-sensor array including four kinds of commercial metal oxide gas sensors (TGS2611, TGS2612, TGS2610, and TGS2602). However, the gases cannot be classified only by these sensor arrays. First, the responses of the sensor array are pretty similar in many circumstances, for example, the responses to a high-concentration ethanol and a lowconcentration carbon monoxide are quite similar, as demonstrated by Figure S1. Second, the inherent variability of the gas sensors across units and across time disperses the responses of the sensing units. Moreover, the principal component analysis (PCA) algorithm is utilized to further evaluate the dataset; as shown in Figure S2, the data cannot be clustered in four classes efficiently. Therefore, only using the gas sensor array, one cannot classify the gases. An olfactory inference system is implemented to classify the gases by an RC system and an ANN, as illustrated in Figure 1. An RC system normally contains thousands of nodes connected randomly and has the ability to extract high dimensional features from inputs. However, the nodes in the conventional reservoir can be replaced by volatile memristive devices (e.g., W/WO 3 /PEDOT: PSS/Pt). The inputs of the RC system based on the memristive devices are the responses of the sensor array, which are converted to spike trains, while the outputs of the RC system are conductance of the memristive devices. A neural network consisting of artificial synapses and artificial neurons is used to classify the gas dataset. The artificial synapses are based on nonvolatile memristive devices (e.g., Pd/W/WO 3 /Pd).

| Encoding process
The encoding process transforms the responses of the gas sensor array to spike trains that can be processed efficiently by the memristive devices. Figure S1 shows the normalized and denoised response curves of the sensor array to the four gases with 10 different concentrations. As representative, the response curves of the sensor TGS2610 to carbon monoxide (red curve) and methane (blue curve) are demonstrated in Figure 2(A).
Response speed and sensing response are two typical characters of a sensor ( Figure S3), so gases can be classified by these two characters. To characterize the response speed, the response curves from 50 to 70 s are sampled with the average of each 0.2 s segment. Figure 2(B) illustrates the segmented results of 56-58 s. Then the differences of the sampled responses between two neighbor segments indicate the response speed ( Figure S3b). Once the defined response speed (Figure 2(C)) is above the threshold (1.0%), a spike is activated and the encoded spike trains for the response speed are shown in Figure 2(D).
The sensing response data from 100 to 120 s are averaged ( Figure S3c). After averaging, the sensing response is encoded to the frequency of the spike trains obeying the Poisson model, 45 as shown in Figure 2(E). Since the sensing response of the sensor TGS2610 is higher for methane, more spikes are generated in the train. The spike trains are 3 s long, the amplitude of each spike is 3 V, and the pulse width is 30 ms. By means of such an encoding approach, the characters of the sensor response are successfully converted to two spike trains, which are more compatible with the memristive devices. Altogether the dataset of the sensor array consisting of eight sensors is converted to 16 spike trains.

| Reservoir computing system based on memristive devices
Reservoir computing (RC) is a framework that can extract features from a spatiotemporal input into a highdimensional feature space. 39 In a conventional RC system, thousands of internal nodes are connected randomly with fixed connection weights, nonlinearly transforming inputs into a high-dimensional space. The role of the reservoir can be realized by volatile memristive devices to decrease the system complexity. 30,32 The nodes in a typical reservoir are connected randomly; data are F I G U R E 1 Schematic diagram of an artificial olfactory inference system based on an RC system and a classifier for gas classification. Gases are detected by the sensor array whose responses are converted to spike trains. The reservoir system based on volatile memristive devices extracts features from the responses of the sensors, while the neural network based on nonvolatile memristive devices realizes the inference transferred from a previous node to a posterior node, in the meantime, the state of each node is accessible for subsequent classification. 40 Alternatively, the conductance of a volatile memristive device depends not only on the programming pulse but also on whether other programming pulses are applied in the past. The short-term memory effect can be obtained natively from a single memristive device, instead of loops formed by multiple nodes. Therefore, a single memristive device can realize the function of the reservoir, whose node states are represented by the memristive conductance. 31,39 We fabricated volatile memristive devices of W/WO 3 / PEDOT:PSS/Pt, whose structure and typical electrical performances are shown in Figure S4. More details about the device were discussed in a previous work. 46 The device shows gradual conductance change and volatile behavior, allowing for forming nodes with a nonlinear function in the reservoir. If two programming pulses are applied close enough, the conductance of the memristive device gradually increases. However, if pulses are not applied for a long time, the memristive device will forget the past stimulus and recover to the initial conductance spontaneously. The device conductance can be modulated by the amplitude and frequency of applied pulses, as discussed in the previous work. 46 Therefore, by using the volatile memristive devices, thousands of nodes in a conventional RC system can be replaced by the memristive devices.
Moreover, as the input dimension expands, more memristive devices are needed in the expanded reservoir, but the nodes are independent of each other in this case, instead of being nonlinearly coupled. 38 As the responses of the sensor array are converted to 16 spike trains, a reservoir consisting of 16 memristive devices is constructed to extract the gas features from the encoded spike trains, and each device processes one of the 16 input spike trains, as shown in Figure 3(A). The inputs are encoded spike trains, and the outputs are conductance of the memristive devices.
In this work, we applied 0.5 ms pulses with 1 ms inter-pulse gap to modulate the conductance of the memristive devices. After each programming pulses, five reading pulses were applied to read the device state. Figure 3(B,C) shows the temporal responses of the memristive devices to the spike trains converted from the characters of the response speeds and the sensing responses (details are given in the supporting information), respectively. The conductance is calculated according to the measured current and the applied reading pulses. Due to the short-term dynamics of the memristive devices, the temporal patterns in the input spike trains lead to diverse but deterministic device responses. The device conductance increases when it is stimulated by a spike, and then decays spontaneously, showing that the device conductance at a specific time depends on the stimulating history. On the other hand, the conductance of the memristive device decreases sharply without stimulus, resulting in the absence of useful information. For example, as shown in Figure 3(B), the far history stimuli are not conveyed in the final conductance of the memristive device. Therefore, the device conductance at 3.0 s does not show a large difference between the two inputs; only using the final conductance of the memristive devices leads to poor classification. To address this problem, the complete response of the memristive device sequence is segmented at an 0.15 s interval, which is illustrated in the inset of Figure 3(B). By measuring and recording the device conductance at the end of each segmentation, we obtain 20 internal values containing sufficient information for a satisfying classification. Since 16 memristive devices are used to compose the reservoir system, the spatiotemporal features of the gases are converted to a 16 Â 20 matrix.

| Strategies for simplifying the feature extraction
With the help of the RC system, the information of methane is converted to a 16 Â 20 matrix, which has 16 characters with 20 time steps extracted from the sensor array. The visualized graph is shown in Figure 4(A), in which the gray level of each pixel represents the conductance of a memristive device at a specific time step, showing the spatiotemporal feature of each gas sample. However, a large number of features increase the complexity of the later classification. Thankfully, a successful classification can be realized with partial features in some situations. 28,38 Three strategies are used to reduce the inputs of the RC system spatially, temporally, and spatiotemporally, so that the sizes of the RC system and the following neural network can be reduced.
As for a spatial strategy, only one of the two sensor characters, either the response speed or the sensing response, as shown in Figure 4(B), is chosen as the representative. Therefore, only one character is converted to eight-spike trains as the inputs of the RC system, and the extracted feature maps of methane are given in Figure 4 (C,D). Since only one characteristic feature is used, the size of the RC system is reduced, enabling half of the memristive devices to process the character. In addition, the number of extracted features equals to the number of the input neurons in the classifier; therefore, the strategy reduces the complexity of the classifier simultaneously.
As for a temporal strategy, decreasing the sampling duration of the sensors is another effective method to reduce the input dimensions of the RC system. As shown in Figure 4(B), the sequences used to encode the response speed are segmented into four parts. Then the spike trains converted from the character of the response speed can be reduced. As for sampling durations of the first 25%, 50%, and 75%, the spike trains converted from them are reduced to 0.75 , 1.5, and 2.25 s, respectively. Meanwhile, the spike train converted from the character of the sensing response is simultaneously reduced to the same length as the ones converted from the response speed. With the shorter input spike trains, the output of the RC system is reduced. For example, when using the first 50% sampling duration, 16 spike trains with 1.5 s long are inputted into the RC system. Then the response of each memristive device is also segmented at an 0.15 s interval and produces 10 conductance values. As shown in Figure 4 (E), the features extracted by the RC system from the first 50% sampling duration have 16 characters with 10 time step, and are converted to a 16 Â 10 matrix, therefore, only 161 neurons are needed in the input layer of the neural network. As for the sampling duration of the middle period, the input spike trains are the same as the first 75% Simplified feature maps using inputs with reduced spatial dimension, in (C) only the response speed is used as the input of the RC system, while in (D) only the sensing response is used. (E) Simplified feature map using inputs with reduced temporal dimension, in which only the first 50% of the sample duration is used. (F,G) Simplified feature maps using inputs with reduced spatial and temporal dimensions sampling duration, while the output of the memristive devices are sampled from 6 to 15 time steps. Due to the less sampling duration, the RC system requires less time to process the shorter input spike trains and produces fewer outputs, which also simplifies the classifier.
To further reduce the input dimension, a third strategy combines the spatial strategy and temporal one. The system uses only partial sampling duration for one of two characters. The features extracted from the middle period sampling duration for the characters of the response speed and the sensing response are shown in Figure 4(F,G), respectively. As only one character is used, eight spike trains are input into the RC system and the output is the features of 6-15 time steps. Therefore, the gas features are converted to an 8 Â 10 matrix. In addition to reduce the number of the memristive devices (only half memristive devices are needed to construct the reservoir), the temporally simplified features for the response speed classify the gases at the beginning of the sensor response period, which is very advantageous for fast gas detection. Therefore, the system can realize gas detection and classification in real-time. 47

| Artificial olfactory inference system
The architecture of an artificial olfactory system is shown in Figure 1; the RC system and the classifier, which is a three-layer neural network, co-construct the artificial olfactory inference system. The neural network (details are given in the supporting information), based on nonvolatile memristive devices of Pd/W/WO 3 /Pd whose structure and electrical properties are given in Figure S5, is used to classify the gas dataset and verify the strategies for simplifying the feature extraction. When using the full feature map (Figure 4(A)) as the input, the neural network should consist of 321 input neurons, 101 hidden neurons and 4 output neurons, and every two neurons on the two neighboring layers are connected via a synapse. When a testing sample is inputted to the neural network, four output neurons show different responses; the neuron with the highest response indicates the classification result.
To test the tolerance of the neural network to nonideality of the connected memristive synapses, two types of synapses are used in the network, as shown in Figure S5: one is the Pd/W/WO 3 /Pd memristive device as discussed in the previous work, 46 performing nonlinear and asymmetrical conductance modulation; the other one is an ideal memristor with ideally linear and symmetrical conductance modulation. According to the Manhattan rule, 48 the synaptic weights are all modulated by applying identical potentiating or depressing pulses.
To better characterize the classifying ability of the neural network, 50% of the data in "Twin gas sensor arrays Data Set" are used as the training samples, while the other half are the testing samples. The 16 Â 20 matrix (320 inputs) is inputted to the neural network. After training, the classification accuracy of the network is given in Figure 5(A). The classification accuracy of the neural network based on the WO 3 -based synapses (~91%) for the testing samples is pretty close to the one based on the ideal synapses (~92%). However, without the RC system, by directly using the encoded spikes trains, the classification accuracy of the network is very low (~53%), as shown in Figure S6. Therefore, the RC system successfully extracts features of each gas, leading to easier classification and high tolerance to the updating nonideality of the memristive synapses. To be more realistic, the following results are all based on the Pd/W/WO 3 /Pd device.
As for the spatially simplified strategy, the sample is converted to an 8 Â 20 matrix (160 features), which are inputted to the neural network containing 161 input neurons and 51 hidden neurons. Figure 5(B) shows the classification accuracy of the network based on the WO 3based synapses. After tens of epochs, the classification accuracy for the testing samples using the feature of the response speed (~92%, blue line in Figure 5(B)) is higher than the one using the feature of the sensing response (~75%, red line in Figure 5(B)). The result indicates that the feature of the response speed attributes to the high accuracy, because the spike trains converted from the response speed also includes features from the sensing response. In other words, more information is contained in the spike trains based on the response speed, thereby improving the classification precision.
As for the temporally simplified strategy, four different sampling durations are utilized. When the sampling duration is 50% (Figure 4(E)), the sample is converted to a 16 Â 10 matrix (160 features), and then inputted to a neural network with the same size as before. As shown in Figure 5(C), the testing accuracies of~72%,~90%, 92%, and~93% are achieved for the first 25%, 50%, 75%, and middle period sampling duration, respectively. When using the middle period sampling duration, the redundant information is got rid of; therefore, the neural network reaches a higher testing accuracy because of the less confusing information.
As for the strategy combining spatial and temporal simplifications, four different sampling durations of one of the two sensor characters are tested. The middleperiod sampled character is converted to an 8 Â 10 matrix (80 features, shown in Figure 4(F,G)), and the matrix is inputted to a neural network with 81 input neurons and 41 hidden neurons. As for the character of the response speed, the testing accuracy of~57%,~92%, ~94%, and~95% are achieved by the first 25%, 50%, 75%, and middle period sampling duration, respectively, as shown in Figure 5(D). Since the gas sensors need plenty of time to react with gases, the middle period of the response speed contains the major features of the reaction period, while gets rid of the redundant information. Therefore, the highest accuracy is achieved by using the middle period sampling duration of the response speed. The accuracy is pretty close to the accuracy (~98%) using both RNN and CNN but higher than those obtained by other algorisms, such as the random forest (~90%), the support vector machine (~92%). 28 An accuracy of 100% was achieved by considering every sensor array as respective dataset, but this work ignored the variation between different sensor arrays. 49 Different from these works, our artificial inference system based on memristive devices is more effective for data collecting and processing in real time, which is advantageous for integrating with terminal devices in realistic scenarios. As for the character of the sensing response, the testing accuracies of~70%,~72%, 74%, and 73% are achieved by using the first 25%, 50%, 75%, and middle period sampling duration, respectively, as shown in Figure S7; such poor classification results are due to the fact that the sensing response contains less information than the character of the response speed, as discussed in the above.

| CONCLUSIONS
In this work, we demonstrate an artificial olfactory inference system consisting of an RC system and an ANN. The RC system is based on the volatile memristive devices of W/WO 3 /PEDOT:PSS/Pt, which successfully F I G U R E 5 Classification accuracy of the artificial olfactory inference system. (A) Classification accuracy for testing samples with two types of artificial synapses, that is, ideal and WO 3 -based ones. (B-D) Classification accuracy for testing samples with reduced (B) spatial, (C) temporal, and (D) spatial and temporal dimensions. The inset of (D) shows the magnified accuracy by using the first 50%, 75%, and middle period input extracts features from the dataset of the gas sensors. The extracted features, represented by the conductance of the memristive devices and simplified by three spatial and temporal strategies, are inputted to the following classifier based on nonvolatile memristive devices of Pd/ W/WO 3 /Pd. An accuracy of~95% is achieved using our RC system and ANNs with simplified inputs.
The artificial olfactory inference system successfully sniff gases, otherwise cannot be recognized by the sensor array directly. Even with the spatiotemporal strategy to simplify the features, the olfactory inference system can also achieve a high accuracy for the gas dataset. Therefore, the olfactory system is effective for data collecting and processing in real time, to achieve gas detection and classification with high efficiency and low power consumption. Moreover, the olfactory system has also the ability to overcome the variation and drift of sensors. By connecting with different types of sensors, the inference system can also realize more functions, such as speech recognition by pressure sensors, and image classification by vision and imaging sensors.