liveBook · Manning

Normalization

As explained in Build AI Drug Discovery Pipelines

Normalization is the rescaling of input values or representations to a standardized magnitude or range.

Normalization rescales features so their magnitudes behave consistently during model training. In molecular graphs, atom feature vectors are divided by their sums, producing vectors that sum to 1 and improving numerical stability. section 11.2.2

Protein residue features use a different strategy: continuous biochemical properties are linearly scaled to [0, 1]. This prevents larger-valued properties from dominating learned representations, while categorical one-hot features remain unsummed. section 11.3.2

Choose normalization according to the representation:

  • Normalize each atom vector by its feature sum; mostly one-hot vectors therefore become quasi-probability distributions. section 11.2.2
  • Scale continuous residue properties between the observed minimum and maximum; encode an unknown residue at the midpoint. section 11.3.2

Atom-vector normalization

For each atom, compute its feature array and divide by sum(feature) plus a small epsilon. The resulting vector sums approximately to 1 without risking division by zero. section 11.2.2

Listing 11.1 Convert SMILES String to Graph Representation
def smile_to_graph(smiles: str) -> Tuple[int, List, List]:
    mol = Chem.MolFromSmiles(smiles)
    if mol is None:
        raise ValueError(f"Invalid SMILES: {smiles}")
    num_atoms = mol.GetNumAtoms()
 
    features = []
    for atom in mol.GetAtoms():    #A
        feature = atom_features(atom)
        features.append(feature / (sum(feature) + 1e-10))
 
    # Extract bonds
    edges = []
    for bond in mol.GetBonds():    #B
        edges.append([bond.GetBeginAtomIdx(), bond.GetEndAtomIdx()])
 
    g = nx.Graph(edges).to_directed()
    edge_index = []
 
    mol_adj = np.zeros((num_atoms, num_atoms))    #C
    for e1, e2 in g.edges:
        mol_adj[e1, e2] = 1
 
    mol_adj += np.matrix(    #D
        np.eye(mol_adj.shape[0])    #D
    )    #D
 
    index_row, index_col = np.where(mol_adj >= 0.5)
    for i, j in zip(index_row, index_col):    #E
        edge_index.append([i, j])
 
    return num_atoms, features, edge_index

Inspect the graph-construction listing to see normalization applied while converting atom features into a molecular graph. section 11.2.2

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Explains sum normalization and min-max scaling with implementation details, but does not develop broader optimization theory.
Examples
Uses atom feature vectors, biochemical residue properties, unknown residues, and Python implementations for graph and protein representations.
What it assumes
Assumes basic feature vectors and molecular or protein representations, while defining normalization strategies through concrete preprocessing code.
What you can do after
Apply it via Python and RDKit-style molecular preprocessing to standardize atom and protein inputs.
How it connects
Connects one-hot encoding, molecular graphs, protein feature matrices, and position-specific scoring matrices.

Also explained in

Compare how 24 books explain normalization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI Drug Discovery Pipelines. The section links point to the parts of the book it draws on.