PolyTorch 0.1.3__tar.gz → 0.1.4__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.
- {polytorch-0.1.3 → polytorch-0.1.4}/PKG-INFO +1 -1
- {polytorch-0.1.3 → polytorch-0.1.4}/polytorch/data.py +27 -1
- {polytorch-0.1.3 → polytorch-0.1.4}/pyproject.toml +1 -1
- {polytorch-0.1.3 → polytorch-0.1.4}/LICENSE +0 -0
- {polytorch-0.1.3 → polytorch-0.1.4}/README.rst +0 -0
- {polytorch-0.1.3 → polytorch-0.1.4}/polytorch/__init__.py +0 -0
- {polytorch-0.1.3 → polytorch-0.1.4}/polytorch/embedding.py +0 -0
- {polytorch-0.1.3 → polytorch-0.1.4}/polytorch/enums.py +0 -0
- {polytorch-0.1.3 → polytorch-0.1.4}/polytorch/loss.py +0 -0
- {polytorch-0.1.3 → polytorch-0.1.4}/polytorch/metrics.py +0 -0
- {polytorch-0.1.3 → polytorch-0.1.4}/polytorch/modules.py +0 -0
- {polytorch-0.1.3 → polytorch-0.1.4}/polytorch/plots.py +0 -0
- {polytorch-0.1.3 → polytorch-0.1.4}/polytorch/util.py +0 -0
|
@@ -12,7 +12,19 @@ from .enums import ContinuousLossType, BinaryLossType, CategoricalLossType
|
|
|
12
12
|
@define(kw_only=True)
|
|
13
13
|
class PolyData(abc.ABC):
|
|
14
14
|
name: str = Factory(lambda self: self.__class__.__name__, takes_self=True)
|
|
15
|
-
loss_weighting: float = 1.0
|
|
15
|
+
loss_weighting: float = field(default=1.0)
|
|
16
|
+
|
|
17
|
+
def __setstate__(self, state):
|
|
18
|
+
# Handle (super_state, our_state) tuple pattern
|
|
19
|
+
if isinstance(state, tuple) and len(state) == 2:
|
|
20
|
+
_, actual_state = state
|
|
21
|
+
else:
|
|
22
|
+
actual_state = state
|
|
23
|
+
|
|
24
|
+
for k, v in actual_state.items():
|
|
25
|
+
setattr(self, k, v)
|
|
26
|
+
if not hasattr(self, "loss_weighting"):
|
|
27
|
+
self.loss_weighting = 1.0
|
|
16
28
|
|
|
17
29
|
@abc.abstractmethod
|
|
18
30
|
def embedding_module(self, embedding_size:int) -> nn.Module:
|
|
@@ -67,6 +79,9 @@ class BinaryData(PolyData):
|
|
|
67
79
|
|
|
68
80
|
raise NotImplementedError(f"Unknown loss type: {self.loss_type} for {self.__class__.__name__}")
|
|
69
81
|
|
|
82
|
+
def __setstate__(self, state):
|
|
83
|
+
super().__setstate__(state)
|
|
84
|
+
|
|
70
85
|
|
|
71
86
|
@define
|
|
72
87
|
class CategoricalData(PolyData):
|
|
@@ -101,6 +116,9 @@ class CategoricalData(PolyData):
|
|
|
101
116
|
|
|
102
117
|
raise NotImplementedError(f"Unknown loss type: {self.loss_type} for {self.__class__.__name__}")
|
|
103
118
|
|
|
119
|
+
def __setstate__(self, state):
|
|
120
|
+
super().__setstate__(state)
|
|
121
|
+
|
|
104
122
|
|
|
105
123
|
@define
|
|
106
124
|
class OrdinalData(CategoricalData):
|
|
@@ -111,6 +129,9 @@ class OrdinalData(CategoricalData):
|
|
|
111
129
|
from .embedding import OrdinalEmbedding
|
|
112
130
|
return OrdinalEmbedding(self.category_count, embedding_size)
|
|
113
131
|
|
|
132
|
+
def __setstate__(self, state):
|
|
133
|
+
super().__setstate__(state)
|
|
134
|
+
|
|
114
135
|
|
|
115
136
|
@define
|
|
116
137
|
class ContinuousData(PolyData):
|
|
@@ -138,6 +159,9 @@ class ContinuousData(PolyData):
|
|
|
138
159
|
def loss_func(self):
|
|
139
160
|
return getattr(F, self.loss_type.name.lower())
|
|
140
161
|
|
|
162
|
+
def __setstate__(self, state):
|
|
163
|
+
super().__setstate__(state)
|
|
164
|
+
|
|
141
165
|
|
|
142
166
|
@define
|
|
143
167
|
class HierarchicalData(PolyData):
|
|
@@ -158,3 +182,5 @@ class HierarchicalData(PolyData):
|
|
|
158
182
|
def loss_module(self):
|
|
159
183
|
return HierarchicalSoftmaxLoss(root=self.root)
|
|
160
184
|
|
|
185
|
+
def __setstate__(self, state):
|
|
186
|
+
super().__setstate__(state)
|
|
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
|