You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the schedule.step() should be called outside train_loader loop, corespondingly:
for epoch in (pbar := tqdm.tqdm(range(n_epochs), desc="Epoch 0")):
correct, total = 0, 0
for x, y in train_loader:
x, y = x.cuda(), y.cuda()
optimizer.zero_grad()
pred = model(x)
loss = criterion(pred, y)
loss.backward()
optimizer.step()
schedule.step() # <-- remove
if len(y.shape) > 1:
y = torch.argmax(y, dim=1)
correct += (torch.argmax(pred, -1) == y).detach().float().sum().item()
total += len(y)
schedule.step() # <-- add
pbar.set_description(f"Epoch {epoch}, Train Acc {correct / total:.3f}")
After fixing the logic, the final results should be like this:
Model
Top-1 Accuracy
Top-1 Acc (schedule outside)
AlexNet
56.6
-
Dino ResNet50
63.7
-
Dino ViT-B/8
74.9
-
AlexNet → DINO ResNet50
60.7
61.9 (+1.2)
AlexNet → DINO ViT-B/8
64.2
67.1 (+2.9)
The text was updated successfully, but these errors were encountered:
wangguanan
changed the title
Since the CosineAnnealingLR is set with n_epochs, the schedule.step() should be called outside the dataloader loop.
The schedule.step() should be called outside the dataloader loop.
Dec 18, 2023
One more thing, using multiple processings can significantly increase data loading speed, i.e. reduce training and inference time, which can be implemented by setting num_workers > 0, correspondingly:
Thanks to the OpenAI and Superalignment Generalization Team's awesome work.
When I reading the code of vision part, I found a minor bug about
CosineAnnealingLR
. Since the learning rate schedule is set by n_epochs not n_iters,the
schedule.step()
should be called outside train_loader loop, corespondingly:After fixing the logic, the final results should be like this:
The text was updated successfully, but these errors were encountered: