|
Research Ideas and Outcomes :
Project Report
|
|
Corresponding author: Stefan Kuhn (stefan.kuhn@ut.ee)
Received: 22 Dec 2025 | Published: 07 Jan 2026
© 2026 Enriko Kroon, Ricardo Borges, Rômulo de Jesus, Stefan Kuhn
This is an open access article distributed under the terms of the Creative Commons Attribution License (CC BY 4.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.
Citation:
Kroon E, Borges R, de Jesus R, Kuhn S (2026) Interpreting 2D-NMR spectra using Grad-CAM. Research Ideas and Outcomes 12: e183261. https://doi.org/10.3897/rio.12.e183261
|
|
It has been shown that it is possible to train a (simple) neural network to classify nuclear magnetic resonance spectra by a substructures either being part of the chemical structure measured or not. We now explore the interpretability of such models using techniques from explainable AI, specifically Grad-CAM. We show that those techniques do not give ideal results in the context of NMR, which would be able to identify individual peaks. On the other hand, they enable a better interpretation of the results than those metrics just based on "right or wrong". We can also confirm the result from our previous work, that the trained network performs well for pure compounds, but its generalisability to mixtures is questionable, a limitation that could only be assumed in the original study.
nuclear magnetic resonance, NMR, machine learning, AI, explainable AI, structure elucidation
The question of determining the actual chemical structure underlying a sensorially perceivable substance, such as the product of a chemical reaction, is a core challenge in chemistry. Analytical chemistry provides a number of techniques to address this problem. Amongst those nuclear magnetic resonance (NMR) spectroscopy is one of the most informative. Each NMR spectrum is characteristic of a specific molecular structure, as different structures produce different spectra. Skilled spectroscopists can infer a structure from spectra, a process known as structure elucidation. For in-depth details of NMR spectroscopy and structure elucidation methodologies, we refer the reader to
The ambition to automate the process of structure elucidation emerged as soon as computer systems became available in chemistry. Software created for this is known as computer-aided structure elucidation (CASE) software (
Whilst ML methods hold significant promise, there are downsides as well. Chief amongst these is their "black-box" nature, as models often produce predictions without providing insight into the underlying reasoning. They produce a result, but there is no explanation given as to why or any visible reasoning. Not only is this unsatisfying for the user, but it also makes users distrust the results. Hence, explainable AI is a critical development. This paper shows some attempts to make the results from
Machine learning, specifically supervised machine learning, works by presenting a model with solved examples of a class of problems and adjusting parameters in the model to approach the solutions. If the model is then presented with unsolved problems, it can apply the knowledge learnt and give a (good) solution. One possible class of models are neural networks, which are loosely modelled on the structure of the human brain. A specific class of neural networks are convolutional neural networks (CNNs), which have proven their strength particularly for interpreting image and other array-like data. That means that they may also be suitable for NMR spectra, as demonstrated in
Example for the three categories of structures, with the characteristic substructure highlighted. Left: Elaidic Acid, bmse000643, middle: Hydroxyindoleacetic Acid, bmse000364, right: α-Cholestan-3-one, bmse000489. Substructure searches exclude side chains on the fatty acid, but allow any groups otherwise.
Class Activation Maps (CAM), originally introduced by
Grad-CAM is more universal than CAM since it does not require a specific architecture. Grad-CAM determines the importance of the features by calculating the gradient in respect to the majority class (or any target class of interest) of the feature maps. Then the given gradients are global-average-pooled over the width and height dimensions to obtain the importance of the neurons. The importance scores are then used as the weight of the corresponding feature maps. By combining these weighted maps, a single localised map is created that highlights the areas of the image that had the most significant impact on the decision of the network. After that, the result is passed through ReLu activation to obtain only the areas that had a positive effect on the network's decision-making process, thus creating a heat map. Gradient-weighted class activation mapping plus plus (Grad-CAM++,
In Fig.
Left: The unchanged HSQC spectrum of a fatty acid (bmse000643). Right: The ideal result of the tool, applied to this spectrum. The tool would highlight exactly those peaks belonging to the atoms in the fatty acid fragment. In the image, the region where important peaks are located is enlarged.
The data used for this experiment are taken from the download site of the Biological Magnetic Resonance Data Bank (
To evaluate the effectiveness of Class Activation Mapping (CAM) methods and neural networks in chemical structure elucidation, a series of heatmap images were generated. The evaluation focuses on comparing the heatmaps of pure substances with those of artificially created mixtures that include the original pure substances. These artificial mixtures are produced by overlaying spectra from the three target compound classes - steroids, fatty acids and indoles - with spectra from compounds that do not belong to any of these subclasses. Each artificial mixture will include spectral data from one of the target classes along with one or two additional spectra from unrelated compounds. This method enables the assessment of the models’ ability to accurately classify relevant substructures and identify the substructure region in the spectra using Grad-CAM and Grad-CAM++ algorithms.
By evaluating pure compounds, the neural network managed to correctly classify all of the substances by both HMBC and HSQC spectra (Fig.
When using artificial mixtures for analysis, it becomes evident that the network partly retains its ability to accurately classify the presence of the three target substructures. This was indicated in \cite{fragments}, where, by using the HMBC spectra, all three examples could be identified correctly and, by using the HSQC spectrum, one of the three examples was identified correctly. An example for this is the HMBC spectrum for a steroid (Fig.
In order to further investigate the effect of mixtures, we checked artificial mixtures of three components (the target substance plus two other substances). In \cite{fragments}, only three of six cases were identified correctly. The heatmaps show a similar picture. In case of the steroid HMBC spectrum (Fig.
By applying the Grad-CAM++ algorithm, the heat maps generated for the pure spectra (Fig.
From our observations, we can draw a number of conclusions about the use of CAMs in structure elucidation.
One observation is that, at least Grad-CAM and Grad-CAM++, do not provide the level of detail which would be needed to identify peaks. This makes the ideal goal of this exercise a target we have not reached.
On the other hand, the heatmaps produced show that, for pure compounds, relevant parts of the spectrum are considered by the networks. On the other hand, when looking at the mixtures, the picture is not clear - in many cases (but not all), parts of the compounds which should not contribute, are used as well. This confirms the results of
Due to this, heat maps, even if not ideal for determining peaks, can help to evaluate a model beyond the usual metrics. As we have seen, using Grad-CAM, we better understand what is going on in the model than without it. In so far, this can serve as a step towards explainable AI. It should be noted that the basis for the application is the use of spectral images and convolutional neural networks, which are commonly used for image analysis.
We have demonstrated that a class activation map, particularly Grad-CAM, can help better understand the results of analysing spectra using neural networks. Whilst we did not achieve our ideal goal, we have demonstrated that the previous results become better understandable and easier to interpret. It is also clear that better models are needed for the mixtures. In general, finer-grained methods than Grad-CAM would be helpful. Finally, more data will help establish a broader base for analysis.
We are grateful to the BMRB project for providing the spectral data used in this paper. Carlos Corbas from MestreLab Research S.L.U, Santiago, Spain and colleagues have kindly helped with data processing.
Conceptualisation, S.K.; methodology, S.K.; software, E.K.; validation, R.M.B., R.P.J.; investigation, S.K., E.K.; writing---original draft preparation, E.K.; writing---review and editing, S.K., R.M.B., R.P.J.; supervision, S.K. All authors have read and agreed to the published version of the manuscript.