Workflow
December 27, 2023Less than 1 minute
Workflow
data, get data ready
build or pick a pretrained model(to suit your problem)
- Pick a loss function & optimizer
- Build a training loop
Fit the model to the data and make a prediction
Evaluate the model
Improve through experimentation
Save and reload your trained model
- data, get data ready
- build or pick a pretrained model(to suit your problem)
- Fit the model to the data (training)
- make a prediction (inference)
- saving and loading a model
- putting it all together
- Evaluate the model
- Improve through experimentation
- Save and reload your trained model
Machine Learning: a game of two parts
- inputs
- numerical encoding
- learns representation(patterns/ features/ weights)
- representation outputs
- Outputs
- get data into a numerical representation
- build a model to learn patterns in that numerical representation
dataset
- training set, always
- validation set, often but not always
- Test set, always
model
algorithm
- Gradient descent
- back propagation
torch.nn
torch.nn.Parameter
torch.nn.Module
torch.optim
torch.Interfere_mode()
Train
loss function
nn.L1Loss()
MAE
optimizer
torch.optim.SGD()
Lr: learning rate 变化的幅度。是 hyperparameter 超参数,自己设置的
module.state_dict()
Training loop
loop through the data
Forward pass to make predictions on data
前向传播
Calculate the loss
计算误差
Optimizer zero grad
Loss backward
反向传播
Optimizer step
epochs
数据、模型、损失函数、优化器、迭代训练
Testing loop
Saving a model in Pytorch
torch.save()
, picletorch.load()
, picletorch.nn.load_state_dict()
, picle