congrads 1.0.5__py3-none-any.whl → 1.0.7__py3-none-any.whl
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.
- congrads/constraints.py +17 -30
- {congrads-1.0.5.dist-info → congrads-1.0.7.dist-info}/METADATA +15 -1
- {congrads-1.0.5.dist-info → congrads-1.0.7.dist-info}/RECORD +6 -6
- {congrads-1.0.5.dist-info → congrads-1.0.7.dist-info}/LICENSE +0 -0
- {congrads-1.0.5.dist-info → congrads-1.0.7.dist-info}/WHEEL +0 -0
- {congrads-1.0.5.dist-info → congrads-1.0.7.dist-info}/top_level.txt +0 -0
congrads/constraints.py
CHANGED
|
@@ -94,8 +94,7 @@ class Constraint(ABC):
|
|
|
94
94
|
defined in the `descriptor`.
|
|
95
95
|
|
|
96
96
|
Note:
|
|
97
|
-
- If `rescale_factor <= 1`, a warning is issued
|
|
98
|
-
adjusted to a positive value greater than 1.
|
|
97
|
+
- If `rescale_factor <= 1`, a warning is issued.
|
|
99
98
|
- If `name` is not provided, a name is auto-generated,
|
|
100
99
|
and a warning is logged.
|
|
101
100
|
|
|
@@ -120,7 +119,7 @@ class Constraint(ABC):
|
|
|
120
119
|
|
|
121
120
|
# Type checking
|
|
122
121
|
validate_iterable("neurons", neurons, str)
|
|
123
|
-
validate_type("name", name,
|
|
122
|
+
validate_type("name", name, str, allow_none=True)
|
|
124
123
|
validate_type("monitor_only", monitor_only, bool)
|
|
125
124
|
validate_type("rescale_factor", rescale_factor, Number)
|
|
126
125
|
|
|
@@ -132,12 +131,13 @@ class Constraint(ABC):
|
|
|
132
131
|
# Perform checks
|
|
133
132
|
if rescale_factor <= 1:
|
|
134
133
|
warnings.warn(
|
|
135
|
-
"Rescale factor for constraint
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
name,
|
|
134
|
+
f"Rescale factor for constraint {name} is <= 1. The network "
|
|
135
|
+
"will favor general loss over the constraint-adjusted loss. "
|
|
136
|
+
"Is this intended behavior? Normally, the rescale factor "
|
|
137
|
+
"should always be larger than 1.",
|
|
140
138
|
)
|
|
139
|
+
else:
|
|
140
|
+
self.rescale_factor = rescale_factor
|
|
141
141
|
|
|
142
142
|
# If no constraint_name is set, generate one based
|
|
143
143
|
# on the class name and a random suffix
|
|
@@ -149,31 +149,18 @@ class Constraint(ABC):
|
|
|
149
149
|
)
|
|
150
150
|
self.name = f"{self.__class__.__name__}_{random_suffix}"
|
|
151
151
|
warnings.warn(
|
|
152
|
-
"Name for constraint is not set. Using
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
# If rescale factor is not larger than 1, warn user and adjust
|
|
156
|
-
if rescale_factor <= 1:
|
|
157
|
-
self.rescale_factor = abs(rescale_factor) + 1.5
|
|
158
|
-
warnings.warn(
|
|
159
|
-
"Rescale factor for constraint %s is < 1, adjusted value \
|
|
160
|
-
%s to %s.",
|
|
161
|
-
name,
|
|
162
|
-
rescale_factor,
|
|
163
|
-
self.rescale_factor,
|
|
152
|
+
f"Name for constraint is not set. Using {self.name}.",
|
|
164
153
|
)
|
|
165
|
-
else:
|
|
166
|
-
self.rescale_factor = rescale_factor
|
|
167
154
|
|
|
168
155
|
# Infer layers from descriptor and neurons
|
|
169
156
|
self.layers = set()
|
|
170
157
|
for neuron in self.neurons:
|
|
171
158
|
if neuron not in self.descriptor.neuron_to_layer.keys():
|
|
172
159
|
raise ValueError(
|
|
173
|
-
f
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
160
|
+
f"The neuron name {neuron} used with constraint "
|
|
161
|
+
f"{self.name} is not defined in the descriptor. Please "
|
|
162
|
+
"add it to the correct layer using "
|
|
163
|
+
"descriptor.add('layer', ...)."
|
|
177
164
|
)
|
|
178
165
|
|
|
179
166
|
self.layers.add(self.descriptor.neuron_to_layer[neuron])
|
|
@@ -675,13 +662,13 @@ class SumConstraint(Constraint):
|
|
|
675
662
|
# weight list dimensions, raise error
|
|
676
663
|
if weights_left and (len(neuron_names_left) != len(weights_left)):
|
|
677
664
|
raise ValueError(
|
|
678
|
-
"The dimensions of neuron_names_left don't match with the
|
|
679
|
-
|
|
665
|
+
"The dimensions of neuron_names_left don't match with the "
|
|
666
|
+
"dimensions of weights_left."
|
|
680
667
|
)
|
|
681
668
|
if weights_right and (len(neuron_names_right) != len(weights_right)):
|
|
682
669
|
raise ValueError(
|
|
683
|
-
"The dimensions of neuron_names_right don't match with the
|
|
684
|
-
|
|
670
|
+
"The dimensions of neuron_names_right don't match with the "
|
|
671
|
+
"dimensions of weights_right."
|
|
685
672
|
)
|
|
686
673
|
|
|
687
674
|
# If weights are provided for summation, transform them to Tensors
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: congrads
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
4
4
|
Summary: A toolbox for using Constraint Guided Gradient Descent when training neural networks.
|
|
5
5
|
Author-email: Wout Rombouts <wout.rombouts@kuleuven.be>, Quinten Van Baelen <quinten.vanbaelen@kuleuven.be>, Peter Karsmakers <peter.karsmakers@kuleuven.be>
|
|
6
6
|
License: Copyright 2024 DTAI - KU Leuven
|
|
@@ -203,6 +203,20 @@ We welcome contributions to Congrads! Whether you want to report issues, suggest
|
|
|
203
203
|
|
|
204
204
|
Congrads is licensed under the [The 3-Clause BSD License](LICENSE). We encourage companies that are interested in a collaboration for a specific topic to contact the authors for more information or to set up joint research projects.
|
|
205
205
|
|
|
206
|
+
## Contacts
|
|
207
|
+
|
|
208
|
+
Feel free to contact any of the below contact persons for more information or details about the project. Companies interested in a collaboration, or to set up joint research projects are also encouraged to get in touch with us.
|
|
209
|
+
|
|
210
|
+
- Peter Karsmakers [ [email](mailto:peter.karsmakers@kuleuven.be) | [website](https://www.kuleuven.be/wieiswie/en/person/00047893) ]
|
|
211
|
+
- Quinten Van Baelen [ [email](mailto:quinten.vanbaelen@kuleuven.be) | [website](https://www.kuleuven.be/wieiswie/en/person/00125540) ]
|
|
212
|
+
|
|
213
|
+
## Contributors
|
|
214
|
+
|
|
215
|
+
Below you find a list of people who contributed in making the toolbox. Feel free to contact them for any repository- or code-specific questions, suggestions or remarks.
|
|
216
|
+
|
|
217
|
+
- Wout Rombouts [ [email](mailto:wout.rombouts@kuleuven.be) | [github profile](https://github.com/rombie18) ]
|
|
218
|
+
- Quinten Van Baelen [ [email](mailto:quinten.vanbaelen@kuleuven.be) | [github profile](https://github.com/quinten-vb) ]
|
|
219
|
+
|
|
206
220
|
---
|
|
207
221
|
|
|
208
222
|
Elevate your neural networks with Congrads! 🚀
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
congrads/__init__.py,sha256=uj36sGjM_ldPgD-0aaWh1b-HspZxqUsC2St97sg_6jg,759
|
|
2
2
|
congrads/checkpoints.py,sha256=AnP5lMT94BiOpT2e0b8QvxhW8bacy_U_eGInBGND6tU,7897
|
|
3
|
-
congrads/constraints.py,sha256=
|
|
3
|
+
congrads/constraints.py,sha256=0NtV6OPMafsOV_Yt2t4sKJvvmbBbF_vIC15QSoa3kNY,32848
|
|
4
4
|
congrads/core.py,sha256=qcoK_P95j-TY17PWlR0zYbExwe19e391LIMbxZiq5Ek,21061
|
|
5
5
|
congrads/datasets.py,sha256=mfpMKfiJjc6tmeez6EPuyd94O54qZt5KFI4Gs5RAhlc,15855
|
|
6
6
|
congrads/descriptor.py,sha256=ml4IRiEcnRoRYiFgIV2BKpfKjWcLpPsTf0f4l0fTt38,4829
|
|
@@ -8,8 +8,8 @@ congrads/metrics.py,sha256=nQuOOVVUeWbxmiFHni9hHFeUd58Gm-Lo0875KG5bHgk,6774
|
|
|
8
8
|
congrads/networks.py,sha256=fW-1YuscWGSDQwjRItcD8-6R37k1-Do6E2g0HsghB4s,3914
|
|
9
9
|
congrads/transformations.py,sha256=0mbEGdanF7_nFh0lnuBVdImtj3wwIGBMsbg8mkFZ-kw,4485
|
|
10
10
|
congrads/utils.py,sha256=uKOxudT0VgOQ1KCa4uXDADt7KIQISLxzwCipdlfchwo,26252
|
|
11
|
-
congrads-1.0.
|
|
12
|
-
congrads-1.0.
|
|
13
|
-
congrads-1.0.
|
|
14
|
-
congrads-1.0.
|
|
15
|
-
congrads-1.0.
|
|
11
|
+
congrads-1.0.7.dist-info/LICENSE,sha256=hDkSuSj1L5IpO9uhrag5zd29HicibbYX8tUbY3RXF40,1480
|
|
12
|
+
congrads-1.0.7.dist-info/METADATA,sha256=fC5J9-jOOPEgE5xbboEeVIol_fBuHvBufibdJbqJmzo,10253
|
|
13
|
+
congrads-1.0.7.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
14
|
+
congrads-1.0.7.dist-info/top_level.txt,sha256=B8M9NmtHbmzp-3APHe4C0oo7aRIWRHWoba9FIy9XeYM,9
|
|
15
|
+
congrads-1.0.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|