relucent 0.2.0__tar.gz → 0.2.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.
- {relucent-0.2.0 → relucent-0.2.2}/PKG-INFO +6 -4
- {relucent-0.2.0 → relucent-0.2.2}/README.md +2 -2
- {relucent-0.2.0 → relucent-0.2.2}/pyproject.toml +4 -2
- {relucent-0.2.0 → relucent-0.2.2}/src/relucent/poly.py +11 -5
- {relucent-0.2.0 → relucent-0.2.2}/src/relucent/__init__.py +0 -0
- {relucent-0.2.0 → relucent-0.2.2}/src/relucent/bvs.py +0 -0
- {relucent-0.2.0 → relucent-0.2.2}/src/relucent/complex.py +0 -0
- {relucent-0.2.0 → relucent-0.2.2}/src/relucent/convert_model.py +0 -0
- {relucent-0.2.0 → relucent-0.2.2}/src/relucent/model.py +0 -0
- {relucent-0.2.0 → relucent-0.2.2}/src/relucent/utils.py +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: relucent
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: Explore the polyhedral complexes of ReLU neural networks.
|
|
4
5
|
Author: Blake B. Gaines
|
|
5
6
|
License-Expression: AGPL-3.0-or-later
|
|
6
7
|
Requires-Dist: pandas>=2.3
|
|
@@ -18,7 +19,8 @@ Requires-Dist: torchvision ; extra == 'cli'
|
|
|
18
19
|
Requires-Dist: pyvis>=0.3 ; extra == 'cli'
|
|
19
20
|
Requires-Dist: kaleido ; extra == 'cli'
|
|
20
21
|
Requires-Python: >=3.13, <3.14
|
|
21
|
-
Project-URL:
|
|
22
|
+
Project-URL: Repository, https://github.com/bl-ake/relucent
|
|
23
|
+
Project-URL: Documentation, https://bl-ake.github.io/relucent/
|
|
22
24
|
Provides-Extra: cli
|
|
23
25
|
Description-Content-Type: text/markdown
|
|
24
26
|
|
|
@@ -26,7 +28,7 @@ Description-Content-Type: text/markdown
|
|
|
26
28
|
[](https://github.com/bl-ake/relucent/releases)
|
|
27
29
|
|
|
28
30
|
# Relucent
|
|
29
|
-
Explore polyhedral complexes
|
|
31
|
+
Explore the polyhedral complexes of ReLU neural networks
|
|
30
32
|
|
|
31
33
|
## Environment Setup
|
|
32
34
|
1. Install Python 3.13
|
|
@@ -65,7 +67,7 @@ Or, get the adjacency graph of top-dimensional cells in the complex as a [Networ
|
|
|
65
67
|
print(cplx.get_dual_graph())
|
|
66
68
|
```
|
|
67
69
|
|
|
68
|
-
View the documentation for this library at
|
|
70
|
+
View the documentation for this library at https://bl-ake.github.io/relucent/
|
|
69
71
|
|
|
70
72
|
## Source Code Structure
|
|
71
73
|
* [model.py](src/relucent/model.py): PyTorch Module that acts as an interface between the model and the rest of the code
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
[](https://github.com/bl-ake/relucent/releases)
|
|
3
3
|
|
|
4
4
|
# Relucent
|
|
5
|
-
Explore polyhedral complexes
|
|
5
|
+
Explore the polyhedral complexes of ReLU neural networks
|
|
6
6
|
|
|
7
7
|
## Environment Setup
|
|
8
8
|
1. Install Python 3.13
|
|
@@ -41,7 +41,7 @@ Or, get the adjacency graph of top-dimensional cells in the complex as a [Networ
|
|
|
41
41
|
print(cplx.get_dual_graph())
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
View the documentation for this library at
|
|
44
|
+
View the documentation for this library at https://bl-ake.github.io/relucent/
|
|
45
45
|
|
|
46
46
|
## Source Code Structure
|
|
47
47
|
* [model.py](src/relucent/model.py): PyTorch Module that acts as an interface between the model and the rest of the code
|
|
@@ -6,7 +6,8 @@ build-backend = "uv_build"
|
|
|
6
6
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "relucent"
|
|
9
|
-
|
|
9
|
+
description = "Explore the polyhedral complexes of ReLU neural networks."
|
|
10
|
+
version = "0.2.2"
|
|
10
11
|
requires-python = ">= 3.13, <3.14"
|
|
11
12
|
dependencies = [
|
|
12
13
|
"pandas>=2.3",
|
|
@@ -35,4 +36,5 @@ cli = [
|
|
|
35
36
|
]
|
|
36
37
|
|
|
37
38
|
[project.urls]
|
|
38
|
-
|
|
39
|
+
Repository = "https://github.com/bl-ake/relucent"
|
|
40
|
+
Documentation = "https://bl-ake.github.io/relucent/"
|
|
@@ -224,13 +224,19 @@ class Polyhedron:
|
|
|
224
224
|
self._finite = self._center is not None
|
|
225
225
|
return self._center, self._inradius
|
|
226
226
|
|
|
227
|
-
def get_hs(self):
|
|
227
|
+
def get_hs(self, data=None, get_all_Ab=False):
|
|
228
228
|
"""Get the halfspace representation of this polyhedron.
|
|
229
229
|
|
|
230
230
|
Computes the halfspaces (inequality constraints) that define the polyhedron
|
|
231
231
|
from all neurons in the network. The result includes constraints from
|
|
232
232
|
every neuron, not just the supporting hyperplanes.
|
|
233
233
|
|
|
234
|
+
Args:
|
|
235
|
+
data: Optional input data to the network for verification. If provided,
|
|
236
|
+
checks that computed outputs match network outputs. Defaults to None.
|
|
237
|
+
get_all_Ab: If True, returns all intermediate affine maps (A, b) for
|
|
238
|
+
each layer instead of just the final halfspaces. Defaults to False.
|
|
239
|
+
|
|
234
240
|
Returns:
|
|
235
241
|
tuple: (halfspaces, W, b) where:
|
|
236
242
|
- halfspaces: Array of shape (n_constraints, n_dim+1) with bias terms
|
|
@@ -238,14 +244,14 @@ class Polyhedron:
|
|
|
238
244
|
- b: Affine transformation bias vector
|
|
239
245
|
"""
|
|
240
246
|
if isinstance(self.bv, torch.Tensor):
|
|
241
|
-
return self.
|
|
247
|
+
return self._get_hs_torch(data, get_all_Ab)
|
|
242
248
|
elif isinstance(self.bv, np.ndarray):
|
|
243
|
-
return self.
|
|
249
|
+
return self._get_hs_numpy(data, get_all_Ab)
|
|
244
250
|
else:
|
|
245
251
|
raise NotImplementedError
|
|
246
252
|
|
|
247
253
|
@torch.no_grad()
|
|
248
|
-
def
|
|
254
|
+
def _get_hs_torch(self, data=None, get_all_Ab=False):
|
|
249
255
|
"""Get halfspaces when the sign sequence is a torch.Tensor.
|
|
250
256
|
|
|
251
257
|
Computes the halfspace representation using PyTorch operations.
|
|
@@ -315,7 +321,7 @@ class Polyhedron:
|
|
|
315
321
|
return halfspaces, current_A, current_b
|
|
316
322
|
|
|
317
323
|
@torch.no_grad()
|
|
318
|
-
def
|
|
324
|
+
def _get_hs_numpy(self, data=None, get_all_Ab=False):
|
|
319
325
|
"""Get halfspaces when the sign sequence is a numpy array.
|
|
320
326
|
|
|
321
327
|
Args:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|