Model Pipeline - Random erasing
This pipeline shows how random erasing helps a computer vision model learn better by randomly hiding parts of images during training. This makes the model stronger and less likely to get confused by small changes.
This pipeline shows how random erasing helps a computer vision model learn better by randomly hiding parts of images during training. This makes the model stronger and less likely to get confused by small changes.
Epochs 1 |***************...............| Loss=1.8 3 |********************..........| Loss=1.2 5 |************************......| Loss=0.9 7 |****************************..| Loss=0.7 10|*******************************| Loss=0.5
| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 1.8 | 0.35 | Model starts learning, loss high, accuracy low |
| 3 | 1.2 | 0.55 | Loss decreases, accuracy improves as model learns features |
| 5 | 0.9 | 0.68 | Random erasing helps model generalize, accuracy rises |
| 7 | 0.7 | 0.75 | Loss continues to drop, model becomes more confident |
| 10 | 0.5 | 0.82 | Training converges with good accuracy and low loss |
random erasing in computer vision training?RandomErasing in torchvision.transforms.p, scale, and ratio are valid for RandomErasing.import torch
import torchvision.transforms as transforms
transform = transforms.Compose([
transforms.RandomErasing(p=1.0, scale=(0.9, 0.9), ratio=(1, 1))
])
image = torch.ones((3, 10, 10))
output = transform(image)
print(output[:, 4:6, 4:6])
What will be the printed output?p=1.0, random erasing always applies. The erased area is set to zero by default.output[:, 4:6, 4:6] (center 2x2) is always covered by the large erased area, so it will be zeros.transform = transforms.RandomErasing(p=0.5)
image = Image.open('cat.jpg')
output = transform(image)transforms.ToTensor() before RandomErasing causes type error.ToTensor().Pass the test and this pattern moves unknown