homa 0.0.18__tar.gz → 0.1.1__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.
- {homa-0.0.18 → homa-0.1.1}/PKG-INFO +1 -1
- {homa-0.0.18 → homa-0.1.1}/pyproject.toml +1 -1
- {homa-0.0.18 → homa-0.1.1}/src/homa/vision/Resnet.py +3 -9
- homa-0.1.1/src/homa/vision/concerns/Trainable.py +26 -0
- homa-0.1.1/src/homa/vision/concerns/__init__.py +1 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa.egg-info/PKG-INFO +1 -1
- {homa-0.0.18 → homa-0.1.1}/src/homa.egg-info/SOURCES.txt +2 -0
- {homa-0.0.18 → homa-0.1.1}/tests/test_ensemble.py +1 -1
- {homa-0.0.18 → homa-0.1.1}/tests/test_resnet.py +2 -2
- {homa-0.0.18 → homa-0.1.1}/tests/test_stochastic_resnet.py +2 -2
- {homa-0.0.18 → homa-0.1.1}/README.md +0 -0
- {homa-0.0.18 → homa-0.1.1}/setup.cfg +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/__init__.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/activations/__init__.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/activations/classes/APLU.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/activations/classes/GALU.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/activations/classes/MELU.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/activations/classes/PDELU.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/activations/classes/SReLU.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/activations/classes/SmallGALU.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/activations/classes/StochasticActivation.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/activations/classes/WideMELU.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/activations/classes/__init__.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/activations/utils.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/cli/HomaCommand.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/cli/namespaces/CacheNamespace.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/cli/namespaces/MakeNamespace.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/cli/namespaces/__init__.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/device.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/ensemble/Ensemble.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/ensemble/__init__.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/ensemble/concerns/CalculatesMetricNecessities.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/ensemble/concerns/HasNetwork.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/ensemble/concerns/HasStateDicts.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/ensemble/concerns/PredictsProbabilities.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/ensemble/concerns/RecordsStateDictionaries.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/ensemble/concerns/ReportsClassificationMetrics.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/ensemble/concerns/ReportsEnsembleAccuracy.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/ensemble/concerns/ReportsEnsembleF1.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/ensemble/concerns/ReportsEnsembleKappa.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/ensemble/concerns/ReportsLogits.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/ensemble/concerns/ReportsSize.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/ensemble/concerns/__init__.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/settings.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/torch/Module.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/torch/__init__.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/torch/helpers.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/utils.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/vision/Model.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/vision/StochasticResnet.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/vision/__init__.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/vision/modules/ResnetModule.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/vision/modules/StochasticResnetModule.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/vision/modules/__init__.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa/vision/utils.py +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa.egg-info/dependency_links.txt +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa.egg-info/entry_points.txt +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa.egg-info/requires.txt +0 -0
- {homa-0.0.18 → homa-0.1.1}/src/homa.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "homa"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.1.1"
|
|
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(y, self.network(x).float())
|
|
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
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|