TMBA 25th FW Track
Machine Learning & Trading
Interpretable ML (III)
Mentor | Yu-Chen (Abner) Den
Date | Nov 10th, 2024
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
2 |
Outline
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
3 |
Outline
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
4 |
Recall Last Part of Interpretable ML (II)
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
5 |
Outline
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
6 |
Backpropagation – Fast Convergence
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
7 |
Backpropagation (Cont’d)
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
8 |
Optimizer
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
9 |
How Learning Rate affects model convergence?
image source: https://www.jeremyjordan.me/nn-learning-rate/
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
10 |
Regularization in NN – Normalization
image source: https://arxiv.org/pdf/1803.08494
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
11 |
Batch Normalization
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
12 |
Layer Normalization
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
13 |
Regularization in NN – Dropout
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
14 |
Supplementary – Why Coding Style Matters
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
15 |
The Only Proper Measure for Code Quality
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
16 |
Naming Rules & Type Annotation
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
17 |
Outline
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
18 |
Training Neural Networks in PyTorch
Code for this slide: https://github.com/AbnerTeng/better-ml/tree/main/pytorch_tutorial
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
19 |
Prerequisite - torch.Tensor
1-D tensor
e.g. a word vector
2-D tensor
e.g. Tabular Data
3-D tensor
e.g. RGB Images
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
20 |
x = torch.tensor([[1, 2], [3, 4]])
x = torch.from_numpy(np.array([[1, 2], [3, 4]])
x = torch.zeros([2, 2])
x = torch.ones([2, 2])
torch.Tensor – Creating Tensors
Shape of tensor
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
21 |
torch.Tensor – Further
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
22 |
Training & Testing Neural Networks in PyTorch
torch.utils.data.Dataset
torch.utils.data.DataLoader
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
23 |
Load Data – torch.utils.data.Dataset
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
24 |
torch.utils.data.Dataset – Implement Map-style dataset
Load data & preprocess
Return the length of dataset
Return the specific feature & target pair
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
25 |
Load Data – torch.utils.data.DataLoader
Batch size
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
26 |
torch.utils.data.DataLoader – parameters
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
27 |
Build PyTorch Model – torch.nn.Module
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
28 |
Training process in PyTorch
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
29 |
Some important method in training process
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
30 |
Loss functions
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
31 |
Lets see the code structure !!!
Move on to the code base
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
32 |
Preview of Next Course
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML
33 |
Appendix I – Internal Covariate Shift
©2024 Yu-Chen Den, SinoPac Holdings | National Taiwan University
Interpretable ML