WorksPhysics and Astronomy
Detecting Atomic Scale Surface Defects in STM of TMDs with Ensemble Deep Learning
Abstract
Atomic-scale defect detection is shown in scanning tunneling microscopy images of single crystal WSe2 using an ensemble of U-Net-like convolutional neural networks. Standard deep learning test metrics indicated good detection performance with an average F1 score of 0.66 and demonstrated ensemble generalization to C-AFM images of WSe2 and STM images of MoSe2. Defect coordinates were automatically extracted from defect detections maps showing that STM image analysis enhanced by machine learning can be used to dramatically increase sample characterization throughput.
Introduction
The relevance of atomic-scale defects on the physical properties of semiconductor devices is well known [1]. This is especially true for devices fabricated from two-dimensional (2D) transition metal dichalcogenides (TMDs), such as tungsten diselenide (WSe) [2]. Point defect detection in 2D TMDs, particularly at the device size scale, is still in its infancy due to the challenges these materials pose to commonly used techniques such as electron microscopy [3] and optical microscopy [4, 5, 6]. Scanning probe microscopy (SPM) techniques, like scanning tunneling microscopy (STM) and conductive atomic force microscopy (C-AFM), can directly image atomic-scale defects in TMD devices but the routine manual image analysis required is a major experimental throughput bottleneck.
Deep learning (DL) has been shown to vastly enhance the capabilities of scanning probe microscopy (SPM) [7, 8, 9, 10, 11, 12]. The analysis of STM images using DL is challenging due to the inherent noise and instability arising from the tip condition and tunneling current contrast mechanism. We report results on applying deep learning to the automatic detection of atom-scale defects in STM images of single crystal WSe. Our results show that an ensemble of U-Net models [13], a convolutional neural network (CNN) which has seen a widespread success of its application to many computer vision problem domains, can overcome challenges imposed by manual defect counting.
Materials & Methods
CVT and Flux Growth of Crystals
All crystals used for this study were synthesized by the self-flux method following previously published methods [14].
Scanning Tunneling Microscopy
The STM images of single crystal discussed and used in this work were acquired using -1.4 V bias voltage and 60 pA tunneling current by a ScientaOmicron Low Temperature STM (LT-STM) with Specs Zurich GmbH's 'Nanonis' SPM controls. This bias was chosen to maximize the sensitivity of STM to charged defects due to its location near the valence band edge, as seen in Figure 1, and we empirically observe the most types of defects at this voltage. The sample temperature and pressure during imaging were approximately 77 K and Torr. STM images were acquired at three scan widths of 50 nm, 100 nm, and 200 nm and three resolutions of 512x512, 1024x1024, and 2048x2048. We used images with nm-to-pixel ratios of 0.049 and 0.098. Electrochemically etched W tips were used as the STM probe. These probes were processed in situ by electron-beam heating followed by conditioning on epitaxial Au(1 1 1) on mica. Conditioning concluded once the well-known Au(1 1 1) herringbone reconstruction and the corresponding surface state in scanning tunneling spectra were resolved [15]. Bulk crystals were attached to the STM sample plates using Epo-Tek H20E silver conductive epoxy along with a ceramic post affixed to the top surface of the crystal. The crystal was exfoliated in-situ without exposure to oxygen using the ceramic post in an adjacent preparation chamber to expose a fresh, clean crystal surface. The tip was aligned to the sample optically.

Figure 1. Average differential conductance of pristine WSe with standard deviation shown as the shaded regions showing n-type character. STM training images were acquired at -1.4 V
Data Preprocessing and Augmentation
The training data included both atomic resolution as well as non-atomic resolution STM images which were plane corrected, quadratically flattened line-by-line, gaussian smoothed, and equalized with contrast limited adaptive histogram equalization to improve feature clarity. These operations were performed using the NumPy and Open-Source Computer Vision packages in Python 3. Data augmentation was accomplished by randomly cropping 60 resolution regions from 38 labeled, parent resolution, STM images covering total area. No linear transformations were applied to avoid introducing non-physical artifacts that can reduce the model’s applicability to STM images. These data were then split into three groups: the training set, the validation set, and the test set. The training and validation sets were used to train the U-Net ensemble and optimize hyperparameters, while the test set was used post-training to measure how well the ensemble learned to generalize.
Deep Learning
Deep learning ensemble creation and training was accomplished using AtomAI, the open-source Pytorch-based package for deep/machine learning analysis of microscopy data using Python 3 [12]. An ensemble of models was trained instead of a single model to obtain information on the variance in detection confidence amongst the 10 U-Net models. Cross entropy loss and the ADAM optimizer were used for training. The following training parameters were used after several rounds of hyperparameter optimization: 500 epochs, learning rate , and batch size 1. After 500 epochs, the weights of each model were stochastically averaged. Training typically took 40 minutes on a single desktop with an Intel i9-11900, Nvidia RTX 1070, and 32 GB of 3200 MHz DDR4 RAM.
Training Data and Ensemble Training
fig:2a shows a typical input image used for training the neural networks. Individual defect instances were manually annotated with bounding boxes and associated qualitative labels to form a dataset of 1382 instances of defects. We classified defects as either peaks or troughs in intensity to train our ensemble. The bounding boxes were used to generate segmentation masks for each STM image where a circle was placed at the center of each bounding box with a characteristic width approximated from manual inspection of height profiles of a small subset of defects. Every pixel within each circle was set to 1 for the trough class or 2 for the peak class. Pixels which correspond to the atomic or noise background were set to 0. An example segmentation mask generated from fig:2a is shown in fig:2b, where the blue color signifies trough-like defects while the yellow color represents peak-like defects. Then, the experimental images and masks were used to train the ensemble of 10 U-Net models. Once training was completed, the U-Net ensemble was applied to full STM images to predict defect segmentation maps, as shown in fig:2c. Detection variance was greatest around the perimeter of charged defects due to the gradual decrease in contrast resulting from the charge halo surrounding these defects. fig:2d shows the coordinates extracted from the defect segmentation map shown in fig:2c overlayed on the STM image shown in fig:2a.

Figure 2. Example of an input, output, and coordinate extraction from ensemble. (a) Example 50 nm * 50 nm STM image (-1.4 V, 60 pA). (b) Segmentation mask produced from the bounding boxes.
Blue is the trough class while yellow is the peak class. These masks were used to train the U-Net model. (c) U-Net segmentation map predicted after training was completed. The yellow color signifies trough-like defects while the purple color represents peak-like defects. (d) Defect XY coordinates extracted from the U-Net segmentation map
Results & Discussion
The generalization performance of the trained ensemble was evaluated using 100 un-seen, labeled test images of WSe to compute the confusion matrix, the receiver-operator-characteristic curve, the precision-recall curve, mean average precision, and the F-score as shown in Figure 3. Figure 3a shows a normalized confusion matrix computed over the test images, without inclusion of the background class, which displays an almost perfect classifier with high values along the diagonal and low values on the off diagonal. This matrix shows that the trained ensemble does not display classification bias despite vast class imbalance in the training data dominated by trough defects. The precision-recall curve is shown in Figure 3b, where a perfect classifier would maximize both precision and recall and achieve a high F score. Here the mean average precision (mAP) of the peak and trough classes were above the 0.5 baseline required of a trustworthy classifier and achieved F scores of 0.69 and 0.63, respectively. The receiver-operator characteristic (ROC) curve shown in Figure 3c displays a high true positive rate at a low false positive rate for every class with an area under the ROC (AUROC) close to 1, far higher than random guessing which would result in an AUROC of 0.5.

Figure 3. U-Net Ensemble Evaluation on 100 Unseen Test STM Images (a) Normalized confusion matrix displaying good generalization of peak and trough detection indicated by high values along the diagonal. (b) Precision-Recall Curves of each class showing a class averaged mAP = 0.78 and F = 0.66. (c) Receiver operator characteristic curves showing a class averaged AUROC = 0.97. Class 0, 1, and 2 are background, troughs, and peaks, respectively
While the U-Net ensemble was trained on STM images of WSe, we found that it demonstrated generalization to images of WSe acquired using C-AFM, and STM images of MoSe, as shown in
Figure 4. Figure 4a shows a 99 nm * 99 nm C-AFM image of single crystal WSe from a similar crystal batch with 1024 * 1024 pixel resolution. Figure 4b shows the coordinates extracted from the defect detections produced by the U-Net ensemble overlayed on the input image shown in Figure 4a. The red dots correspond with peak-type defects while the green dots represent the trough-type defects. While the detections are not perfect, the ensemble displays remarkable generalization to C-AFM images without any re-training on new labeled data. We attribute this capability to the similarity of the image contrast mechanism between C-AFM and STM [16]. Figure 4c shows a 50 nm * 50 nm STM image of MoSe aquired at -1.9 V with 512 * 512 resolution. Similar to Figure 4b, Figure 4d shows the coordinates of defects detected by the U-Net ensemble overlayed on the input STM image shown in Figure 4c. Here the generalization of the trained ensemble to STM images of MoSe is attributed to the similarity of point defect appearances across 2H TMD material systems which include selenium.

(a)

(b)

(c)

(d)
Figure 4. Example U-Net Ensemble Generalization to C-AFM and MoSe a) 1024 * 1024 resolution, 99 nm x 99 nm C-AFM image of single crystal WSe. b) Detected defect coordinates overlayed on top of the C-AFM image shown in figure 4a. c) 512 * 512 resolution, 50 nm * 50 nm STM image
of single crystal acquired at -1.9 V d) Defect coordinates extracted from the defect detection map produced using the STM image shown in Figure 4c as input to the trained ensemble.
Conclusion
We have applied deep learning to automatically detect atomic-scale defects in STM images of single crystal . We found that an ensemble of models with the U-Net architecture could reliably detect defects in STM images of this crystal and could generalize to other SPM methods and other materials. This represents another step towards the data-driven optimization of TMD synthesis and characterization.
Authors Contributions
All authors contributed to the conception, design, and implementation of the study. Material synthesis was performed by Luke Holtzman. Material preparation was performed by Stephanie D. Lough. STM data collection of was performed by Darian Smalley. C-AFM data collection was performed by Kaikui Xu. STM data collection of was performed by Madisen Holbrook. All deep learning and data analysis was performed by Darain Smalley. The first draft of the manuscript was written by Darian Smalley. All authors commented on previous versions of the manuscript. All authors read and approved the final manuscript.
Conflict of Interest
On behalf of all authors, the corresponding author states that there is no conflict of interest.
Data Availability
Data is available from the authors upon reasonable request.
Funding
Not applicable.
References
- [1]R. C. Newman, “Defects in silicon,” Reports on Progress in Physics, vol. 45, no. 10, pp. 1163–1210, Oct. 1982, doi: 10.1088/0034-4885/45/10/003.DOI
- [2]C. D. English, G. Shine, V. E. Dorgan, K. C. Saraswat, and E. Pop, “Improved Contacts to MoS2 Transistors by Ultra-High Vacuum Metal Deposition,” Nano Lett, vol. 16, no. 6, pp. 3824–3830, Jun. 2016, doi: 10.1021/acs.nanolett.6b01309.DOI
- [3]S. Kretschmer, T. Lehnert, U. Kaiser, and A. V. Krasheninnikov, “Formation of Defects in Two-Dimensional MoS2 in the Transmission Electron Microscope at Electron Energies below the Knock-on Threshold: The Role of Electronic Excitations,” Nano Lett, vol. 20, no. 4, pp. 2865–2870, Apr. 2020, doi: 10.1021/acs.nanolett.0c00670.DOI
- [4]S. Mignuzzi et al., “Effect of disorder on Raman scattering of single-layer MoS2,” Phys Rev B, vol. 91, no. 19, p. 195411, May 2015, doi: 10.1103/PhysRevB.91.195411.DOI
- [5]R. T. Sam, T. Umakoshi, and P. Verma, “Defect-related anomalous low-frequency Raman scattering in a few-layered MoS2,” Applied Physics Express, vol. 13, no. 7, p. 072003, Jul. 2020, doi: 10.35848/1882-0786/ab9a91.DOI
- [6]R. Kato, T. Umakoshi, R. T. Sam, and P. Verma, “Probing nanoscale defects and wrinkles in MoS2 by tip-enhanced Raman spectroscopic imaging,” Appl Phys Lett, vol. 114, no. 7, p. 073105, Feb. 2019, doi: 10.1063/1.5080255.DOI
- [7]A. Ghosh, B. Sumpter, O. Dyck, S. V Kalinin, and M. Ziatdinov, “Ensemble learning and iterative training (ELIT) machine learning: applications towards uncertainty quantification and automated experiment in atom-resolved microscopy,” 2021. doi: https://doi.org/10.1038/s41524-021-00569-7.
- [8]M. A. Ziatdinov and S. V Kalinin, “Robust Feature Disentanglement in Imaging Data via Joint Invariant Variational Autoencoders: from Cards to Atoms,” 2021. doi: https://doi.org/10.48550/arXiv.2104.10180.
- [9]Y. Liu et al., “Decoding the shift-invariant data: applications for band-excitation scanning probe microscopy,” 2021. doi: 10.1088/2632-2153/ac28de.DOI
- [10]S. V. Kalinin, A. Ghosh, R. Vasudevan, and M. Ziatdinov, “From atomically resolved imaging to generative and causal models,” Nat Phys, vol. 18, no. 10, pp. 1152–1160, Oct. 2022, doi: 10.1038/s41567-022-01666-0.DOI
- [11]S. V Kalinin, O. Dyck, S. Jesse, and M. Ziatdinov, “Exploring order parameters and dynamic processes in disordered systems via variational autoencoders,” 2021. [Online]. Available: https://www.science.orgDOI
- [12]M. Ziatdinov, A. Ghosh, T. Wong, and S. V. Kalinin, “AtomAI: A Deep Learning Framework for Analysis of Image and Spectroscopy Data in (Scanning) Transmission Electron Microscopy and Beyond,” May 2021, doi: 10.1038/s42256-022-00558-8.
- [13]O. Ronneberger, P. Fischer, and T. Brox, “U-Net: Convolutional Networks for Biomedical Image Segmentation,” 2015, pp. 234–241. doi: 10.1007/978-3-319-24574-4_28.DOI
- [14]S. Liu et al., “Two-Step Flux Synthesis of Ultrapure Transition-Metal Dichalcogenides,” ACS Nano, vol. 17, no. 17, pp. 16587–16596, Sep. 2023, doi: 10.1021/acsnano.3c02511.DOI
- [15]W. Chen, V. Madhavan, T. Jamneala, and M. F. Crommie, “Scanning Tunneling Microscopy Observation of an Electronic Superlattice at the Surface of Clean Gold,” Phys Rev Lett, vol. 80, no. 7, pp. 1469–1472, Feb. 1998, doi: 10.1103/PhysRevLett.80.1469.DOI
- [16]S. A. Sumaiya, J. Liu, and M. Z. Baykara, “True Atomic-Resolution Surface Imaging and Manipulation under Ambient Conditions via Conductive Atomic Force Microscopy,” ACS Nano, vol. 16, no. 12, pp. 20086–20093, Dec. 2022, doi: 10.1021/acsnano.2c08321.DOI