# A CNN-Based Method for Heavy-Metal Ion Detection
## 3 CNN Structure
### Dataset Acquisition  
In this study, the HMI dataset was built using \(Cd^{2+}\), \(Zn^{2+}\), and \(Cu^{2+}\) as examples.  
**Data acquisition:** Tests were carried out using square-wave voltammetry. The square-wave voltammetry parameters were set to (Init = \(-\)0.7 V, Final = 0.3 V, Increase = 0.005 V, Amplitude = 0.025 V, and Frequency = 25 Hz). A single sampling yielded 400 current data units, and to prevent a high chance of errors in the data, each input data unit consisted of 2 separate test results. We extracted a set of 200 data units from each of the odd columns and a set of 200 data units from each of the even columns, for a total of 4 sets of 2 measurements. These 4 groups were arranged in order to form a 4 \(\times\) 200 data cell as shown in Equations (15) and (16):  
\[A_{1}=(a_{1},a_{2},\cdots,a_{400}),A_{2}=(a_{1}^{\prime},a_{2}^{\prime},\cdots,a_{400}^{\prime}) \tag{15}\]  
\[A^{\prime}=\left[\begin{array}{c}a_{1},a_{3},\cdots,a_{399}\\ a_{2},a_{4},\cdots,a_{400}\\ a_{1}^{\prime},a_{3}^{\prime},\cdots,a_{399}^{\prime}\\ a_{2}^{\prime},a_{4}^{\prime},\cdots,a_{400}^{\prime}\\ \end{array}\right]_{4\times 200} \tag{16}\]  
**Dataset creation:** Data were collected for 12 solutions of cadmium chloride, zinc chloride, and copper chloride with concentration gradients of 0.2 g/L, 0.5 g/L, 1 g/L, and 2 g/L. One data unit was obtained from every two samples. We set each solution to be sampled 50 times, making up 25 data units, with a total of 300 data units as the original dataset.  
**Data augmentation:** Firstly, the data obtained from the acquisition were of the order of magnitude \(10^{-3}\)A, expanding the data 1000 times to reduced gradient loss. These 300 data units were extended by adding 1% white noise to obtain 1200 data units. These data were used as the input dataset for the neural network. This expansion scheme did not affect the important peak and height features of the original electrochemical measurements but broadened the size of the dataset. To establish the accuracy of the model when training, the data needed were classified into two sets: a training set (70%) as well as a testing set (30%).  
The results of a particular data measurement for each concentration were taken and combined into a single data cell, which was produced as a grayscale image. The grayscale of the image from black to white represents the data from small to large. As can be seen in Figure 8, each grayscale image has an area that is approximately white. The position of this region corresponds to the position of the peak in the original data, and the degree of brightness of the region corresponds to the height of the peak. In a conventional square-wave polarimetric analysis, the main features extracted are the half-wave potential as well as the peak height [8]. The peak potential is related to the ion species, and the peak height is related to the ion concentration. From a visual point of view, the following dataset in Figure 8a provides a visual representation of the features to be extracted. Figure 8b shows the visual representation of the data features extracted from Figure 8a.