Tensor encoding deep learning
Use when when you have validated SMILES strings or RDKit molecule objects representing chemical structures and need to feed them into a pre-trained deep learning model (such as PS2MS, NEIMS, or DeepEI) that expects fixed-size numerical tensor inputs.From its SKILL.md
npx -y skills add HolobiomicsLab/asb-skill-collections --skill tensor-encoding-deep-learningAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
6.8 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it
Tensor Encoding for Deep Learning
Summary
Convert parsed molecular structures (SMILES, canonical molecule objects, or extracted descriptors) into fixed-size numerical tensor representations compatible with deep learning model input layers. This skill bridges chemical representation and neural network inference by standardizing feature dimensions and value ranges.
When to use
When you have validated SMILES strings or RDKit molecule objects representing chemical structures and need to feed them into a pre-trained deep learning model (such as PS2MS, NEIMS, or DeepEI) that expects fixed-size numerical tensor inputs. Specifically, when the downstream task is mass spectrum prediction, chemical fingerprint generation, or similarity-based analyte matching that relies on encoded features rather than raw molecular graphs.
When NOT to use
- Input is already a pre-computed feature matrix or fingerprint array ready for model inference — skip directly to model prediction.
- The downstream model accepts raw SMILES strings or molecule objects directly without requiring tensor encoding (rare; most deep learning architectures require numerical tensors).
- The chemical structures are too large, complex, or contain elements/bonds not supported by RDKit, leading to parsing failure or incompatible descriptor extraction.
Inputs
- SMILES strings (text file or list)
- RDKit molecule objects
- Canonical molecular structure representations
Outputs
- Encoded feature matrix (NumPy array)
- Encoded feature matrix (HDF5 file)
- Fixed-size numerical tensors compatible with model input layers
How to apply
Parse and validate input SMILES strings using RDKit to generate canonical molecule objects. Extract molecular descriptors and structural features (atom types, bond connectivity, graph topology) relevant to the target deep learning architecture. Encode these features into a fixed-size numerical array matching the model's input layer dimensions, typically by flattening or pooling molecular graphs into dense vectors. Normalize or standardize feature values (e.g., z-score, min-max scaling) according to the model's training specifications to ensure numerical stability. Serialize the resulting tensor into NumPy array or HDF5 format for batch processing. Validate output tensor shape against model input signature and verify value ranges fall within expected bounds.
Related tools
- RDKit (Parse, validate, and extract molecular descriptors and structural features (atom types, bond connectivity, graph topology) from SMILES strings into canonical molecule objects required by the tensor encoder) — https://www.rdkit.org/docs/Install.html
Evaluation signals
- Output tensor shape exactly matches the model's input layer dimensions (e.g., if model expects [batch_size, 256] features, verify all encoded matrices conform to this shape).
- Feature values fall within expected normalized ranges (e.g., 0–1 for min-max scaling, mean ≈ 0 and std ≈ 1 for z-score normalization) after standardization.
- No NaN or infinite values present in the encoded tensor; all missing or invalid molecular features are handled consistently (e.g., masked, zero-filled, or rejected with clear error logging).
- Round-trip consistency: re-decoding or visualizing a subset of encoded tensors recovers recognizable molecular properties (atom counts, bond types, connectivity patterns) matching the input SMILES.
- Batch processing produces tensors with stable shape and value distributions across multiple SMILES inputs, with no rank mismatches or silent feature truncation.
Limitations
- RDKit may fail to parse invalid, malformed, or non-standard SMILES strings, requiring validation and error handling upstream.
- Molecular descriptors extracted by RDKit are sensitive to tautomerization, stereochemistry, and aromaticity perception; canonical SMILES generation helps but does not eliminate all ambiguity.
- Fixed-size tensor encoding loses some information from large or structurally diverse molecules (e.g., if flattening a variable-length graph into a static vector); architecture choice (pooling strategy, dimensionality reduction) must balance expressiveness against computational cost.
- Normalization and standardization are data-dependent; parameters (min, max, mean, std) must be computed on the training set and applied consistently to test/inference data, or model performance degrades.
- The PS2MS system integrates this encoding with NEIMS (mass spectrum prediction) and DeepEI (chemical fingerprint generation); mismatch between encoder output and these downstream models' expected input formats will cause silent failures or poor predictions.
Evidence
- [other] Load SMILES strings for candidate NPS structures from input file. Parse and validate SMILES using RDKit molecular toolkit to generate canonical molecule objects.: "Load SMILES strings for candidate NPS structures from input file. Parse and validate SMILES using RDKit molecular toolkit to generate canonical molecule objects."
- [other] Extract molecular descriptors and structural features (atom types, bond connectivity, graph topology) required by PS2MS architecture.: "Extract molecular descriptors and structural features (atom types, bond connectivity, graph topology) required by PS2MS architecture."
- [other] Encode features into fixed-size numerical tensor format matching the model's input layer dimensions.: "Encode features into fixed-size numerical tensor format matching the model's input layer dimensions."
- [other] Normalize or standardize feature values according to model training specifications.: "Normalize or standardize feature values according to model training specifications."
- [other] Output encoded feature matrix in NumPy array or HDF5 format.: "Output encoded feature matrix in NumPy array or HDF5 format."
- [readme] rdkit - build the c++ code from the source and install python package from conda: "rdkit - build the c++ code from the source and install python package from conda"
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.