Model Pipeline - torchvision pre-trained models
This pipeline uses a pre-trained model from torchvision to classify images. It starts with input images, processes them through the model, and outputs predicted labels with confidence scores.
Jump into concepts and practice - no test required
This pipeline uses a pre-trained model from torchvision to classify images. It starts with input images, processes them through the model, and outputs predicted labels with confidence scores.
Loss
1.0 |***************
0.8 |************
0.6 |********
0.4 |*****
0.2 |***
0.0 +----------------
1 2 3 4 5 Epochs
| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 0.75 | 0.65 | Initial training loss and accuracy using fine-tuning on a small dataset |
| 2 | 0.50 | 0.78 | Loss decreased and accuracy improved after second epoch |
| 3 | 0.35 | 0.85 | Model continues to learn, showing better predictions |
| 4 | 0.28 | 0.89 | Training converging with lower loss and higher accuracy |
| 5 | 0.22 | 0.92 | Final epoch shows good performance on training data |
torchvision pre-trained models?torchvision.models.resnet18(weights=torchvision.models.ResNet18_Weights.IMAGENET1K_V1).import torch import torchvision.models as models model = models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1) model.eval() inputs = torch.randn(8, 3, 224, 224) outputs = model(inputs) print(outputs.shape)
model = torchvision.models.resnet18(weights=torchvision.models.ResNet18_Weights.IMAGENET1K_V1) inputs = torch.randn(1, 3, 224, 224) outputs = model(inputs)What is the likely mistake?
model.eval() to disable dropout and batch norm updates.model.eval(), so outputs may be incorrect or inconsistent.model.eval() before prediction. -> Option Cmodel.fc with input features 512 and output 1000 classes.model.fc with a new Linear layer with 512 inputs and 5 outputs.