Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

vit_unit_test.py 1.5 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  1. import unittest
  2. from super_gradients.common.object_names import Models
  3. from super_gradients.training.dataloaders.dataloaders import classification_test_dataloader
  4. from super_gradients import Trainer
  5. from super_gradients.training.metrics import Accuracy, Top5
  6. from super_gradients.training import models
  7. class TestViT(unittest.TestCase):
  8. def setUp(self):
  9. self.arch_params = {"image_size": (224, 224), "patch_size": (16, 16), "num_classes": 10}
  10. self.train_params = {
  11. "max_epochs": 2,
  12. "lr_updates": [1],
  13. "lr_decay_factor": 0.1,
  14. "lr_mode": "StepLRScheduler",
  15. "lr_warmup_epochs": 0,
  16. "initial_lr": 0.1,
  17. "loss": "CrossEntropyLoss",
  18. "optimizer": "SGD",
  19. "criterion_params": {},
  20. "optimizer_params": {"weight_decay": 1e-4, "momentum": 0.9},
  21. "train_metrics_list": [Accuracy(), Top5()],
  22. "valid_metrics_list": [Accuracy(), Top5()],
  23. "metric_to_watch": "Accuracy",
  24. }
  25. def test_train_vit(self):
  26. """
  27. Validate vit_base
  28. """
  29. trainer = Trainer("test_vit_base")
  30. model = models.get(Models.VIT_BASE, arch_params=self.arch_params, num_classes=5)
  31. trainer.train(
  32. model=model, training_params=self.train_params, train_loader=classification_test_dataloader(), valid_loader=classification_test_dataloader()
  33. )
  34. if __name__ == "__main__":
  35. unittest.main()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...