homa 0.0.18__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of homa might be problematic. Click here for more details.

Files changed (59) hide show
  1. {homa-0.0.18 → homa-0.1.2}/PKG-INFO +1 -1
  2. {homa-0.0.18 → homa-0.1.2}/pyproject.toml +1 -1
  3. {homa-0.0.18 → homa-0.1.2}/src/homa/vision/Resnet.py +3 -9
  4. homa-0.1.2/src/homa/vision/concerns/Trainable.py +26 -0
  5. homa-0.1.2/src/homa/vision/concerns/__init__.py +1 -0
  6. {homa-0.0.18 → homa-0.1.2}/src/homa.egg-info/PKG-INFO +1 -1
  7. {homa-0.0.18 → homa-0.1.2}/src/homa.egg-info/SOURCES.txt +2 -0
  8. {homa-0.0.18 → homa-0.1.2}/tests/test_ensemble.py +1 -1
  9. {homa-0.0.18 → homa-0.1.2}/tests/test_resnet.py +2 -2
  10. {homa-0.0.18 → homa-0.1.2}/tests/test_stochastic_resnet.py +2 -2
  11. {homa-0.0.18 → homa-0.1.2}/README.md +0 -0
  12. {homa-0.0.18 → homa-0.1.2}/setup.cfg +0 -0
  13. {homa-0.0.18 → homa-0.1.2}/src/homa/__init__.py +0 -0
  14. {homa-0.0.18 → homa-0.1.2}/src/homa/activations/__init__.py +0 -0
  15. {homa-0.0.18 → homa-0.1.2}/src/homa/activations/classes/APLU.py +0 -0
  16. {homa-0.0.18 → homa-0.1.2}/src/homa/activations/classes/GALU.py +0 -0
  17. {homa-0.0.18 → homa-0.1.2}/src/homa/activations/classes/MELU.py +0 -0
  18. {homa-0.0.18 → homa-0.1.2}/src/homa/activations/classes/PDELU.py +0 -0
  19. {homa-0.0.18 → homa-0.1.2}/src/homa/activations/classes/SReLU.py +0 -0
  20. {homa-0.0.18 → homa-0.1.2}/src/homa/activations/classes/SmallGALU.py +0 -0
  21. {homa-0.0.18 → homa-0.1.2}/src/homa/activations/classes/StochasticActivation.py +0 -0
  22. {homa-0.0.18 → homa-0.1.2}/src/homa/activations/classes/WideMELU.py +0 -0
  23. {homa-0.0.18 → homa-0.1.2}/src/homa/activations/classes/__init__.py +0 -0
  24. {homa-0.0.18 → homa-0.1.2}/src/homa/activations/utils.py +0 -0
  25. {homa-0.0.18 → homa-0.1.2}/src/homa/cli/HomaCommand.py +0 -0
  26. {homa-0.0.18 → homa-0.1.2}/src/homa/cli/namespaces/CacheNamespace.py +0 -0
  27. {homa-0.0.18 → homa-0.1.2}/src/homa/cli/namespaces/MakeNamespace.py +0 -0
  28. {homa-0.0.18 → homa-0.1.2}/src/homa/cli/namespaces/__init__.py +0 -0
  29. {homa-0.0.18 → homa-0.1.2}/src/homa/device.py +0 -0
  30. {homa-0.0.18 → homa-0.1.2}/src/homa/ensemble/Ensemble.py +0 -0
  31. {homa-0.0.18 → homa-0.1.2}/src/homa/ensemble/__init__.py +0 -0
  32. {homa-0.0.18 → homa-0.1.2}/src/homa/ensemble/concerns/CalculatesMetricNecessities.py +0 -0
  33. {homa-0.0.18 → homa-0.1.2}/src/homa/ensemble/concerns/HasNetwork.py +0 -0
  34. {homa-0.0.18 → homa-0.1.2}/src/homa/ensemble/concerns/HasStateDicts.py +0 -0
  35. {homa-0.0.18 → homa-0.1.2}/src/homa/ensemble/concerns/PredictsProbabilities.py +0 -0
  36. {homa-0.0.18 → homa-0.1.2}/src/homa/ensemble/concerns/RecordsStateDictionaries.py +0 -0
  37. {homa-0.0.18 → homa-0.1.2}/src/homa/ensemble/concerns/ReportsClassificationMetrics.py +0 -0
  38. {homa-0.0.18 → homa-0.1.2}/src/homa/ensemble/concerns/ReportsEnsembleAccuracy.py +0 -0
  39. {homa-0.0.18 → homa-0.1.2}/src/homa/ensemble/concerns/ReportsEnsembleF1.py +0 -0
  40. {homa-0.0.18 → homa-0.1.2}/src/homa/ensemble/concerns/ReportsEnsembleKappa.py +0 -0
  41. {homa-0.0.18 → homa-0.1.2}/src/homa/ensemble/concerns/ReportsLogits.py +0 -0
  42. {homa-0.0.18 → homa-0.1.2}/src/homa/ensemble/concerns/ReportsSize.py +0 -0
  43. {homa-0.0.18 → homa-0.1.2}/src/homa/ensemble/concerns/__init__.py +0 -0
  44. {homa-0.0.18 → homa-0.1.2}/src/homa/settings.py +0 -0
  45. {homa-0.0.18 → homa-0.1.2}/src/homa/torch/Module.py +0 -0
  46. {homa-0.0.18 → homa-0.1.2}/src/homa/torch/__init__.py +0 -0
  47. {homa-0.0.18 → homa-0.1.2}/src/homa/torch/helpers.py +0 -0
  48. {homa-0.0.18 → homa-0.1.2}/src/homa/utils.py +0 -0
  49. {homa-0.0.18 → homa-0.1.2}/src/homa/vision/Model.py +0 -0
  50. {homa-0.0.18 → homa-0.1.2}/src/homa/vision/StochasticResnet.py +0 -0
  51. {homa-0.0.18 → homa-0.1.2}/src/homa/vision/__init__.py +0 -0
  52. {homa-0.0.18 → homa-0.1.2}/src/homa/vision/modules/ResnetModule.py +0 -0
  53. {homa-0.0.18 → homa-0.1.2}/src/homa/vision/modules/StochasticResnetModule.py +0 -0
  54. {homa-0.0.18 → homa-0.1.2}/src/homa/vision/modules/__init__.py +0 -0
  55. {homa-0.0.18 → homa-0.1.2}/src/homa/vision/utils.py +0 -0
  56. {homa-0.0.18 → homa-0.1.2}/src/homa.egg-info/dependency_links.txt +0 -0
  57. {homa-0.0.18 → homa-0.1.2}/src/homa.egg-info/entry_points.txt +0 -0
  58. {homa-0.0.18 → homa-0.1.2}/src/homa.egg-info/requires.txt +0 -0
  59. {homa-0.0.18 → homa-0.1.2}/src/homa.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: homa
3
- Version: 0.0.18
3
+ Version: 0.1.2
4
4
  Summary: A curated list of machine learning and deep learning helpers.
5
5
  Author-email: Taha Shieenavaz <tahashieenavaz@gmail.com>
6
6
  Requires-Python: >=3.7
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "homa"
7
- version = "0.0.18"
7
+ version = "0.1.2"
8
8
  description = "A curated list of machine learning and deep learning helpers."
9
9
  authors = [
10
10
  { name="Taha Shieenavaz", email="tahashieenavaz@gmail.com" },
@@ -1,18 +1,12 @@
1
1
  import torch
2
2
  from .modules import ResnetModule
3
3
  from .Model import Model
4
+ from .concerns import Trainable
4
5
 
5
6
 
6
- class Resnet(Model):
7
+ class Resnet(Model, Trainable):
7
8
  def __init__(self, num_classes: int, lr: float):
8
9
  super().__init__()
9
10
  self.network = ResnetModule(num_classes)
10
- self.optimizer = torch.optim.SGD(self.network.parameters(), lr=lr, momentum=0.9)
11
11
  self.criterion = torch.nn.CrossEntropyLoss()
12
-
13
- def train(self, x: torch.Tensor, y: torch.Tensor):
14
- self.network.train()
15
- self.optimizer.zero_grad()
16
- loss = self.criterion(x, y)
17
- loss.backward()
18
- self.optimizer.step()
12
+ self.optimizer = torch.optim.SGD(self.network.parameters(), lr=lr, momentum=0.9)
@@ -0,0 +1,26 @@
1
+ from torch import Tensor
2
+ from torch.utils.data.dataloader import DataLoader
3
+ from ...device import get_device
4
+
5
+
6
+ class Trainable:
7
+ def __init__(self, *args, **kwargs):
8
+ super().__init__(*args, **kwargs)
9
+
10
+ def train(self, x: Tensor | DataLoader, y: Tensor | None = None):
11
+ if y is None and isinstance(x, DataLoader):
12
+ self.train_dataloader(x)
13
+ return
14
+ self.train_tensors(x, y)
15
+
16
+ def train_tensors(self, x: Tensor, y: Tensor):
17
+ self.network.train()
18
+ self.optimizer.zero_grad()
19
+ loss = self.criterion(self.network(x).float(), y)
20
+ loss.backward()
21
+ self.optimizer.step()
22
+
23
+ def train_dataloader(self, dataloader: DataLoader):
24
+ for x, y in dataloader:
25
+ x, y = x.to(get_device()), y.to(get_device())
26
+ self.train_tensors(x, y)
@@ -0,0 +1 @@
1
+ from .Trainable import Trainable
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: homa
3
- Version: 0.0.18
3
+ Version: 0.1.2
4
4
  Summary: A curated list of machine learning and deep learning helpers.
5
5
  Author-email: Taha Shieenavaz <tahashieenavaz@gmail.com>
6
6
  Requires-Python: >=3.7
@@ -47,6 +47,8 @@ src/homa/vision/Resnet.py
47
47
  src/homa/vision/StochasticResnet.py
48
48
  src/homa/vision/__init__.py
49
49
  src/homa/vision/utils.py
50
+ src/homa/vision/concerns/Trainable.py
51
+ src/homa/vision/concerns/__init__.py
50
52
  src/homa/vision/modules/ResnetModule.py
51
53
  src/homa/vision/modules/StochasticResnetModule.py
52
54
  src/homa/vision/modules/__init__.py
@@ -1,6 +1,6 @@
1
1
  import pytest
2
2
  from homa.ensemble import Ensemble
3
- from homa.models import Resnet
3
+ from homa.vision import Resnet
4
4
 
5
5
 
6
6
  @pytest.fixture
@@ -1,7 +1,7 @@
1
1
  import pytest
2
2
  import torch
3
- from homa.models import Resnet, Model
4
- from homa.models.modules import ResnetModule
3
+ from homa.vision import Resnet, Model
4
+ from homa.vision.modules import ResnetModule
5
5
 
6
6
 
7
7
  @pytest.fixture
@@ -1,7 +1,7 @@
1
1
  import pytest
2
2
  import torch
3
- from homa.models import StochasticResnet, Model
4
- from homa.models.modules import ResnetModule
3
+ from homa.vision import StochasticResnet, Model
4
+ from homa.vision.modules import ResnetModule
5
5
 
6
6
 
7
7
  @pytest.fixture
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes