Hands on AI II
Module 1: Machine Learning Fundamentals & Neural Networks
Data Representation
- Tabular Data: Organized in rows (samples) and columns (features). Described by a feature vector and a label . A full dataset of samples is represented by a feature matrix and label vector :
- Images: Represented in 3 dimensions: Height, Width, and Channels (e.g., RGB).
- Sequences: Ordered elements useful for time series, molecule design, or text.
Supervised vs. Unsupervised Learning
- Unsupervised Learning: Learns structure without target labels (e.g., k-Means, Hierarchical Clustering, DBSCAN, Gaussian Mixture Models).
- Supervised Learning: Learns mapping from inputs to target labels (Classification for discrete labels, Regression for numerical labels).
Empirical Risk Minimization (ERM) & Loss
The generalization error (risk) over a joint probability distribution is:
In practice, we minimize the empirical risk on our dataset of size :
Linear and Logistic Regression
- Linear Regression: Predicts numerical values. Uses Mean-Squared Error (MSE) loss:
- Logistic Regression: Applies the sigmoid/logistic function to a linear transformation for binary classification, yielding probabilities :
where .
Softmax Function
Generalization of sigmoid for multi-class classification. The probability of belonging to class is:
Neural Networks & Convolutional Neural Networks (CNNs)
- Feed-Forward Networks: Map inputs through hidden layers using weight matrices and bias vectors combined with a non-linear activation function :
- CNNs: Utilize receptive fields and shared weight matrices (kernels). Reusing kernels across image positions provides translation invariance and reduces parameters. Layers include convolutions, non-linearities, and pooling (e.g., Average Pooling, Max Pooling).
Module 2: Network Optimization & Vanishing Gradients
Gradient Descent
Iterative method to minimize the loss function by taking steps proportional to the negative gradient, with learning rate :
Regularization
Technique to prevent overfitting.
- L1 Regularization:
- L2 Regularization (Weight Decay):
Backpropagation and the Chain Rule
For nested functions , the derivative is:
Derivatives of Activation Functions:
- Sigmoid Derivative:
Since , multiplying many gradients in deep networks shrinks the gradient toward zero (Vanishing Gradient Problem). - ReLU Derivative:
Module 3: Recurrent Neural Networks (RNNs) & LSTMs
Standard RNNs
Designed for sequence data . The hidden state at timestep concatenates the previous output with current input :
Trained via Back Propagation Through Time (BPTT). Suffers heavily from vanishing/exploding gradients due to sequential unrolling.
Long Short-Term Memory (LSTM)
Mitigates vanishing gradients using a Constant Error Carousel (CEC) and gates:
- Forget Gate: Decides what to erase from .
- Input Gate: Decides what to write into .
- Output Gate: Decides what to read from to form .
- Cell Candidate:
- Cell State Update: (Identity activation, preserving gradients)
- Hidden State Output:
Module 4: Natural Language Processing & Transformers
Language Modeling
The probability of the next word given previous words is modeled as:
- Negative Log Likelihood Loss:
Overall loss over sequence of length : - Perplexity:
Transformers and Attention
Instead of recurrent sequential steps, transformers use self-attention to globally weigh token relevance, enabling full parallelization:
Module 5: Machine Learning in Drug Discovery
- Quantitative Structure-Activity Relationship (QSAR): Uses ML to predict bioactivity based on numerical representations of molecular structure (e.g., SMILES strings, MOL/SDF graphs).
- Generative Models: Autoencoders (VAE), GANs, and RL are used to explore the chemical space of potential molecules to perform inverse molecular design.
- Protein Folding: Mapping amino acid sequences to 3D conformations (e.g., AlphaFold).
Module 6: Reinforcement Learning
Markov Decision Process (MDP)
Defined by States ( ), Actions ( ), Transition probabilities ( ), and Rewards ( ). The agent learns a policy to maximize cumulative reward.
Q-Learning
Approximates the Q-Value Function , the expected reward of taking action in state and acting optimally thereafter. Update rule: