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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: PolyTorch
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: Embeddings and loss functions for different data types.
5
5
  License: Apache-2.0
6
6
  Keywords: pytorch,deep learning,command-line interface
@@ -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)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "PolyTorch"
3
- version = "0.1.3"
3
+ version = "0.1.4"
4
4
  description = "Embeddings and loss functions for different data types."
5
5
  authors = ["Robert Turnbull <robert.turnbull@unimelb.edu.au>"]
6
6
  license = "Apache-2.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes