2026 Volume 35 Issue 7
Article Contents

Bohan Li, Xinyuan Zhang, Guanhua Chen, Lin Chen. Prediction of material parameters of spin textures from LTEM images by machine learning models CNN and ViT[J]. Chinese Physics B, 2026, 35(7): 077507. doi: 10.1088/1674-1056/ae5db1
Citation: Bohan Li, Xinyuan Zhang, Guanhua Chen, Lin Chen. Prediction of material parameters of spin textures from LTEM images by machine learning models CNN and ViT[J]. Chinese Physics B, 2026, 35(7): 077507. doi: 10.1088/1674-1056/ae5db1

Prediction of material parameters of spin textures from LTEM images by machine learning models CNN and ViT

  • Received Date: 23/12/2025
    Accepted Date: 24/03/2026
    Available Online: 01/07/2026
通讯作者: 陈斌, bchen63@163.com
  • 1. 

    沈阳化工大学材料科学与工程学院 沈阳 110142

  1. 本站搜索
  2. 百度学术搜索
  3. 万方数据库搜索
  4. CNKI搜索

Figures(7)

Article Metrics

Article views(115) PDF downloads(0) Cited by(0)

Access History

Prediction of material parameters of spin textures from LTEM images by machine learning models CNN and ViT

Abstract: Machine learning (ML) models were trained to predict the Dzyaloshinskii–Moriya interaction constant D and anisotropy constant K of spin textures from Lorentz transmission electron microscopy (LTEM) images. Two ML models, convolutional neural network (CNN) and vision transformer (ViT), were trained, tested and employed to predict the values of D and K. Firstly, training and testing datasets composed of 9300 topological spin textures were prepared using the micromagnetic simulation method with the values of D and K randomly chosen. Secondly, the performance of the CNN model for predicting D and K values was investigated by varying the number of training data, the pooling process, and the number of fully connected layers, which indicated high prediction accuracies. Thirdly, better performance of the ViT model for predicting D and K values was achieved with the coefficient of determination R2 reaching as high as 0.9987 and 0.9991 for predicting D and K values, respectively. Particularly, the reliance on synthetic data and noise robustness was discussed. Finally, the prediction abilities of CNN and ViT models were evaluated and compared. The results of this research indicate that the ML models can achieve the material parameters directly and effectively from LTEM images, and this process may contribute to the design of advanced devices based on the topological spin textures.

1.   Introduction
  • Utilizing both the charge and the intrinsic spin of the electron, spintronic devices present superior performances such as low power consumption, non-volatility, high speed, etc.[1,2] Recently, spintronic devices based on topological spin textures have been attracting more and more attentions, which rely on creating, moving, and detecting nanoscale spin textures.[3,4] Therefore, the morphologies or the magnetic distributions of the spin textures, which are determined by material parameters such as Dzyaloshinskii–Moriya interaction (DMI) constant D and anisotropy constant K, are significant for functionality designs.[5,6] As an antisymmetric interaction, DMI exists widely in non-centrosymmetric magnetic bulk compounds and thin layers with the breaking of inversion symmetry, which favors non-collinear alignment of neighboring spins.[7] Kinds of topologically spin textures can be realized through competitions between DMI, Heisenberg exchange interactions, anisotropy strength and other contributing energies. Therefore, it is important to manipulate the parameter values to realize designed spin texture configurations through experimental material synthesis methods. At meantime, it is also very necessary to obtain the parameter values of the designed spin textures through experimental characterization methods. For example, the K value can be determined through measuring the M–H loops by SQUID, or measuring the resonance field along different crystallographic directions,[8,9] and the D value can be determined by Brillouin light scattering method or propagating spin-wave spectroscopy,[10] which are more complicated.

    Particularly, the magnetic distributions of the spin textures are related to the material parameters, which indicates that the parameters should be obtained by analyzing the morphologies using techniques such as Lorentz transmission electron microscopy (LTEM)[11–13] or magnetic force microscopy (MFM).[14–16] So, it is suggested that the well-trained machine learning (ML) models can be employed to analyze the morphologies and to predict the material parameters.[17–19] In recent years, the rapid development of artificial intelligence, particularly neural networks, has introduced a powerful data-driven approach to solving complex physical problems.[20–23] Neural networks, with their ability to automatically extract intricate mappings between input features and output results through extensive data learning, offer a promising alternative for fast and accurate predictions.[24–27] It is reported that Mehmood et al. used convolutional neural network (CNN) models to predict the exchange constant and saturation magnetization and identify the vortex helicity from MFM images.[28] McCray et al. proposed an AI-enabled phase-retrieval method for LTEM which allows quantitative phase reconstruction of in-situ data and can also enable near real-time quantitative magnetic imaging.[29,30]

    Compared with MFM, LTEM offers higher spatial resolution by calculating the phase shift of the transmission electron beam.[11] In this work, we employed CNN models and vision transformer (ViT) models to predict the material parameters D and K by analyzing the LTEM images. Before model optimization, training and testing datasets must be prepared, which are LTEM images with known values of D and K. Considering that it is complicated to get large numbers of LTEM images with varied values of D and K experimentally, the micromagnetic simulation method was employed to generate abundant LTEM images with randomly chosen D and K. Subsequently, the CNN and ViT models were trained and optimized. Finally, the prediction abilities of the two ML models were evaluated and compared.

2.   Model and method
  • Figure 1 presents the framework of this work. In this study, we construct and optimize a machine-learning CNN model and a machine-learning ViT model in order to predict the values of the parameters D and K from simulated LTEM images.

    Firstly, training datasets and testing datasets were generated by micromagnetic simulation software Ubermag with embedded OOMMF codes before training the ML models.[31] Experimentally, LTEM can be performed to image the topologically distributed spin textures. In LTEM, a parallel electron beam with a typical energy of 200 kV–300 kV is incident on the magnetic sample. The charged electrons are deflected by the Lorentz force caused by the magnetic field in the sample. This causes a phase shift ∅m∼(kx,ky) in the electron beam compared with a beam travelling through vacuum. Here, the Ubermag micromagnetic software is used to construct magnetic samples with different topological spin textures, and based on this, to simulate the phase shift that would be recovered by electron holography. The ground static state of the topological spin textures can be realized by calculating the minimum value of the total energy of the magnetic system Etot. Etot can be given by

    which includes Eex for exchange energy, EK for anisotropy energy, Ezeeman for Zeeman energy, EDM for DMI energy, and Ed for demagnetization energy. The magnetic phase shift ∅m∼(kx,ky) of the electron beam can be calculated by[32]

    where μ0 is the vacuum permeability, k is the k-vector in Fourier space and k⊥ is defined as

    Specifically, a Tikhonov filter is used to avoid singularities in Fourier space, and kc is the radius of the filter. MI∼(kx,ky) is the integrated magnetization along the path of the electron beam. Based on the above theory, several software programs are developed to simulate the LTEM images from key parameters such as PyLorentz,[33] Genius,[34] and MALTS.[35] In this work, the mag2exp module in Ubermag was used to generate the LTEM images. The simulation method applied in mag2exp shares the same underlying physical principles with other simulation tools which have been experimentally verified in the field. Due to the fact that mag2exp takes into account a more detailed magnetic moment distribution, the simulated LTEM images would have higher resolution and reliability.[36]

    The topological spin textures were realized in an FeGe magnetic disc with a radius of 50 nm and a thickness of 2 nm. In the simulations, the typical parameters in the FeGe are as follows:[37–40] exchange stiffness constant Aex = 0.4 × 10−11 J/m, saturation magnetization Ms = 3.84 × 105 A/m. The external applied static magnetic field H is 0.5 × 105 A/m. The ranges of parameters D (from 0 to 5 × 10−3 J/m2) and K (from 0 to 10 × 105 J/m3) used in the simulations are based on experimentally reported values, but appropriately extended beyond current experimental limits to cover the physically meaningful interval where stable topological spin textures can be generated. The simulated mesh cell is 2 nm × 2 nm × 2 nm. 9300 different topological spin textures were constructed with the values of D and K randomly chosen. Then, the corresponding LTEM images were collected, which were divided into training datasets with 8500 LTEM images and testing datasets with 800 LTEM images.

    In order to ensure that the model can learn the inherent physical correlation between parameters (D, K) and magnetic properties rather than memorizing specific sample features, we constructed the dataset and split the training/testing sets following strict physical and statistical principles. A full set of samples covering the physically reasonable range of D and K was generated. All D and K values were generated randomly within this range, and the corresponding spin texture data (magnetization distribution images and LTEM images) were obtained through micromagnetic simulations without any artificial screening or selection of grid points, ensuring the full dataset has sufficient physical variance. The training data and testing data were chosen randomly from the full set of samples, to ensure that both the training and testing sets uniformly cover the entire distribution range of D and K. In particular, no testing data were accessed or used in any stage of the model training, which completely avoids data leakage in the training process.

    Secondly, two ML models, CNN and ViT, were chosen to be trained, optimized, and tested based on the datasets. It is known that the ViT model significantly outperforms traditional CNN model by effectively capturing long-range dependencies through its multi-head self-attention mechanism, thereby overcoming the local receptive field limitations inherent in CNNs.[41–44] This capability is crucial for accurately predicting the multiple parameters from complex LTEM images. As shown in Fig. 1, CNN model employs a hierarchy of convolutional layers with learnable filters to perform automatic feature extraction and translation-invariant classification by progressively aggregating simpler local patterns into more complex and global representations.[41,42] ViT model applies the transformer architecture to compute vision tasks, the core idea of which is to segment the image into patches of fixed size and input them as a sequence into the transformer encoder for processing. The complete ViT model is composed of patch embedding, position embedding, transformer encode, and MLP head.[43,44] Finally, the prediction abilities of the two ML models were compared and evaluated. During evaluating the training effect and the prediction accuracy, the coefficient of determination R2 and root-mean-square error (RMSE) were introduced to comprehensively assess model performances, which can be calculated by[45,46]

3.   Results and discussion
  • Before training and optimizing the ML models, we studied the stability of the topological spin textures, which composed the training and testing datasets. As shown in Fig. 2(a), the K–D phase diagram presents three different magnetic states, which are ferromagnetic (FM) state, skyrmion state and maze state. Figures 2(b)–2(e) present the spin distributions of the typical topological spin textures from the 9300 simulated images, and figures 2(f)–2(i) present the corresponding simulated LTEM images. From Fig. 2(a) we can see that, larger D is favor to realize maze state, larger K is favor to realize FM state. Especially, skyrmion state can be achieved by manipulating the D and K values precisely.

    As shown in Fig. 2(b), FM state presents uniform magnetization distributions, while as shown in Fig. 2(c), a radially symmetrical skyrmion is realized with the spin magnetizations rotating 180° from the core to its boundary. Figures 2(d) and 2(e) show the maze states of the topological spin textures, which present labyrinthine patterns or stripe networks. Meanwhile, the corresponding simulated LTEM images in Figs. 2(g), 2(h), and 2(i) also present the identical phase shift characteristics to the magnetization distributions. Based on the K–D phase diagram, 9300 spin textures are obtained with the value of D randomly chosen in the range from 0 to 5 × 10−3 J/m2, and K randomly chosen in the range from 0 to 10 × 105 J/m3. To further demonstrate the phase distributions of the spin textures, we also calculated the K–D phase diagrams when H = 0 and H = 1.0 × 105 A/m, which can be seen in Fig. S1 in supplementary materials.

  • Firstly, the CNN model was trained, optimized, and used to predict the values of D and K. Before training the model, the training datasets were standardized to ensure the consistency of the data and the stability of the model. The images were resized to 224 × 224 pixels to fit the input requirements of the pre-trained model. Average pooling was used in the feature extraction process, and the number of fully connected layers is 4. During training, the MSE was utilized as the loss function, coupled with the Adam optimizer for parameter optimization. The batch size is 8 and the learning rate is 0.001. In each training batch, the model performed forward propagation to generate predictions, subsequently evaluated the performance based on the MSE loss between predicted and actual values, and updated parameters via backpropagation. The entire training process spanned 200 epochs. After training, 200 testing data were used to evaluate the prediction accuracy. Fig. S2 presents the distributions of the training data and testing data, which indicate a uniform and random spatial distribution within the physically reasonable range, with no obvious sample clustering, blank areas, or grid-like aggregation.

    Figures 3(a) and 3(b) present the performance of the CNN model on predicting the values of D and K with 2000 training data and testing data. We can see that the model achieves high accuracy in predicting D and K values. The coefficient of determination R2 can be as high as 0.989 on the training data and 0.988 on the testing data for predicting D values, while 0.987 on the training data and 0.977 on the testing data for predicting K values. In order to evaluate the influence of dataset sizes on the training and predicting effects, three other groups with 500, 1000, and 5000 training data are used to optimize the CNN model, the performances of which can be seen in Fig. S3 in supplementary materials.

    Figure 3(c) presents the values of R2 with increasing training data from 500 to 5000. It can be seen that the values of R2 indicate obviously worse performance on predicting K values compared with predicting D values based on 500 training data. With training data increasing from 500 to 2000, the performance on predicting both D and K values improves significantly, especially for predicting K values. Then, the values of R2 increase slightly when the training data increases from 2000 to 5000, which indicates slight improvements in predictive ability. Meanwhile, we examine the values of the loss function with different training dataset sizes. Figure 3(d) presents the loss convergence over training epochs for 2000 training data and the inset presents the loss value at the 200th epoch with increasing training data. We can see that the loss value at the 200th epoch keeps dropping with the training data increasing from 500 to 2000, and then increases slightly with the training data increasing to 5000, which also indicates that a dataset of 2,000 is already adequate to achieve a good prediction performance.

    Further, we tried to optimize the CNN model in order to get better performance. Here, we compare the prediction abilities using max pooling and average pooling which are two commonly chosen methods in the feature extraction process.[46] Figure 4(a) presents the values of R2 for predicting D and K values with 2000 training data and 200 testing data. Considering the main purpose of pooling is spatial invariance, dimensionality reduction and feature emphasis, it can be seen that the R2 values using max pooling are smaller than the R2 values using average pooling on training data for predicting D values and on testing data for predicting K values. Meanwhile, the R2 values using max pooling are larger than the R2 values using average pooling on training data for predicting K values and on testing data for predicting D values. The results show that the two pooling strategies yield similar overall prediction accuracy and exhibit no significant difference in model performance for the magnetic texture parameter identification task.

    In addition, we investigated the performance of the CNN model with different numbers of fully connected layers. Figure 4(b) presents the R2 for predicting D and K values when the number of fully connected layers is 2, 4, and 8. The training data and testing data are still 2000 and 200, respectively. We can see that the R2 values are lower than 0.5 for predicting K values and lower than 0.9 for predicting D values with 2 layers. Then, the model performs better with 4 layers and 8 layers. Particularly, a slight improvement is achieved when the layer number increases from 4 to 8, which indicates a saturation in the number of layers.

  • Secondly, the ViT model was trained, optimized, and used to predict the values of D and K. Before model training, data preprocessing was performed which was the same as that for the CNN model. After completing the data preprocessing and loading, we employed a custom ML model based on the ViT-Base architecture. The patch size used for the input images was 16 × 16. During training, the MSE was utilized as the loss function, coupled with the Adam optimizer for parameter optimization. The batch size is 8 and the learning rate is 0.001. The entire training process spanned 200 epochs. The performance of the ViT model on predicting the values of D and K with 500 training data and 2000 training data are presented in Figs. 5(a), 5(b) and 5(c), 5(d), respectively. It can be seen that better performance is achieved in predicting D and K values than when using the CNN model. The R2 values can reach as high as 0.9987 on the training data and 0.9879 on the testing data for predicting D values, while they are 0.9991 on the training data and 0.9880 on the testing data for predicting K values with 2000 training data points. Even when the number of training data points decreases to 500, the R2 values are still higher than 0.99 on the training data and the testing data for predicting D values. Meanwhile, the R2 value is higher than 0.99 on the training data for predicting K values, but achieves a smaller value of 0.9745 on the testing data. Particularly, it can be seen in Fig. 5(c) that the ViT model performs worse in prediction accuracy when the D values range from 0 to about 0.625 × 10−3 J/m2, while it achieves excellent prediction accuracy when the D values range from 0.625 × 10−3 J/m2 to 5.0 × 10−3 J/m2. Meanwhile, the prediction abilities for D values are obviously better than those for K values, which also show good performance. In addition, two other groups with 1000 and 5000 training data points were used to optimize the CNN model, the performance of which can be seen in Fig. S4 in supplementary materials. Meanwhile, we investigated the performance of the ViT model with different batch sizes. Figure S5 presents the values of R2 with the batch size increasing from 4 to 32 for predicting the values of D and K based on 2000 training data points and 200 testing data points. It is indicated that the variations in the R2 values for predicting both D and K values based on the testing data are distinct, especially for the R2 in predicting the value of K, with the values first increasing when the batch number changes from 4 to 8 and then decreasing when the batch number changes from 8 to 32. Particularly, the values of R2 corresponding to both D and K values based on the training data vary slightly with the changing batch numbers and indicate good performance.

    In particular, it can be noticed that the significant outlier phenomena in the prediction of parameter D with small D values by the ViT model can be observed. It is suggested that when the D value is small, the system tends to be in the ferromagnetic state, which can also be seen in the phase diagram, and its corresponding LTEM characteristics are not sufficiently distinct, which makes this parameter difficult to predict accurately. LTEM images of the typical FM states with small D values can be seen in Fig. S6 of supplementary materials

    To evaluate the prediction abilities of the ViT model and the CNN model, we compared the values of R2 and RMSE as we increase the number of training data from 500 to 5000, as shown in Fig. 6. The variations of R2 and RMSE values indicate that the ViT model presents distinctly better performance than the CNN model, especially when the number of training data decreases to 500. Particularly, the improvements in prediction ability are more obvious for predicting the values of K than predicting the values of D.

    It is suggested that the ViT model demonstrates superior performance in predicting parameters K and D from LTEM images through its self-attention mechanism and positional encoding. The self-attention mechanism in ViT removes the local receptive field constraint and naturally matches the dual local–global nature of magnetic textures. At the patch level (16 × 16), self-attention accurately encodes fine local structures such as the skyrmion core, magnetization rotation, and local defect features.[43,44] In particular, through global token interaction, self-attention directly models long-range spatial dependencies across the entire image, including the global symmetry and collective behavior of magnetic textures — key physical properties that cannot be fully represented by local CNN operations. In addition, magnetic systems are governed by long-range interactions (DM interaction, exchange interaction, dipolar interaction). The global receptive field of self-attention is inherently more consistent with the non-local nature of magnetism than the local inductive bias of CNNs. Therefore, the ViT model demonstrates stronger performance than the CNN model in this specific task of analyzing magnetic texture images. Specifically, we have constructed a dedicated dataset of skyrmions with continuously tuned domain wall widths without considering any noise or disturbance effects. Quantitative results show that our model can accurately identify small differences in skyrmion domain wall width, with recognition precision far exceeding the limit of human visual discrimination. The performance of the ViT model in predicting the values from 100 testing data points (all skyrmion states) can be seen in Fig. S7 in supplementary materials.

    In particular, the reliance on synthetic data and noise robustness should be considered. Our training and validation datasets are entirely generated via the Ubermag/OOMMF micromagnetic simulation framework, which produces idealized LTEM images free of experimental artifacts. Experimental LTEM images usually suffer from some non-ideal effects such as Poisson noise, shot noise, thickness variations, and bend contours.[47,48] Here, we have implemented two types of noise injection schemes. Firstly, we added an irregular fluctuating field hfluct to modify the Hamiltonian to generate the LTEM images with the non-ideal effects.[44] Secondly, we investigated the noise robustness by injecting Poisson noise into the original simulated LTEM images.

    As shown in Fig. 7(a), the domain wall between up-magnetization and down-magnetization becomes indistinct with increasing the strength of the fluctuating σ from 0 mOe (1 Oe = 79.5775 A⋅m−1) to 30 mOe. Figure 7(b) presents the R2 on training data and testing data with increasing σ. We can see that the R2 values remain almost unchanged on the training data and testing data for predicting D values with increasing the strength of the fluctuation. Meanwhile, the R2 values remain almost unchanged on the training data for predicting K and keep decreasing on the testing data with increasing the strength of the fluctuation. We can see that the R2 value decreases to 0.7943 on the testing data for predicting K with σ = 30 mOe, which indicates a poor predictive ability. Fig. S8 presents the distributions of the training data and testing data to indicate a uniform and random spatial distribution.

    As shown in Fig. 7(c), the LTEM images of a typical maze state of topological spin texture degenerate obviously with dose level (DOSE) from 1.0 to 0.05 by Poisson noise injection. Similar to the results that we added an irregular fluctuating field to simulate the non-ideal effects, the R2 values keep almost unchanged on the training data and testing data for predicting D values and on the training data for predicting K with increasing the strength of the fluctuating. Meanwhile, the R2 values keep decreasing on the testing data with the dose level change to DOSE = 0.05, which gives R2 = 0.8323 indicating a poor prediction ability.

    It can be seen that the prediction of parameter D remains relatively stable under the added fluctuating field or Poisson noise, which confirms the robustness of our model to a certain extent. Meanwhile, the prediction accuracy of parameter K decreases significantly when unstable factors are introduced. Compared with DMI constant D, magnetic anisotropy K may be more closely related to domain wall curvature, local magnetization gradient, fine texture and sharpness of domain boundaries, which are all small-scale image features and are easily affected by a fluctuating field or Poisson noise. To improve the robustness of the K prediction, it is suggested that future work focus on introducing perturbation-resilient feature extraction and adding noise-aware training or adversarial training to enhance anti-interference ability. For clarity and better readability, the performance of the ViT model in predicting the values under the above non-ideal effects can be seen in Figs. S9 and S10 in the supplementary materials.

4.   Conclusion
  • In conclusion, we used machine learning models, CNN, and ViT, to achieve the material parameters of topological spin textures from simulated LTEM images prepared by the micromagnetic simulation method. Compared with the CNN model, the ViT model presents better performance in achieving D and K values. The coefficient of determination R2 could reach values as high as 0.9987 and 0.9991 for predicting D and K values, respectively. Finally, the reliance on synthetic data and noise robustness was discussed. Generally, material parameters of topological spin textures such as DMI constant D or anisotropy constant K cannot be obtained through LTEM images directly by experimental methods, but these correlative structure-property relationships can be learned by ML models and the properties can be predicted by the trained ML models. However, we must realize that this ML-assisted parameter prediction work will be more significant and have greater application value if the experimental LTEM images can be used as the training dataset. This process may contribute to the exploration of the topological spin textures and the design of advanced spintronic devices.

Figure (7)  Reference (48)

Catalog

    /

    DownLoad:  Full-Size Img  PowerPoint
    Return
    Return