Explore the polyhedral complexes of ReLU neural networks.
Project description
Relucent
Explore the polyhedral complexes of ReLU neural networks
Environment Setup
- Install Python 3.13
- Install PyTorch
- Run
pip install relucent
Getting Started
To see if the installation has been successful, try plotting the complex of a randomly initialized network in 2 dimensions like this:
from relucent import Complex, get_mlp_model
network = get_mlp_model(widths=[2, 10, 5, 1])
cplx = Complex(network)
cplx.bfs()
fig = cplx.plot(bound=10000)
fig.show()
The "NN" object returned by get_mlp_model inherits from torch.nn.Module, so you can train and manipulate it just like you're used to :)
Given some input point, you could get a minimal H-representation of the polyhedron containing it like this:
import numpy as np
input_point = np.random.random(network.input_shape)
p = cplx.point2poly(input_point)
print(p.halfspaces[p.shis, :])
You could also check the average number of faces of all polyhedrons with:
sum(len(p.shis) for p in cplx) / len(cplx)
Or, get the adjacency graph of top-dimensional cells in the complex as a NetworkX Graph with:
print(cplx.get_dual_graph())
View the documentation for this library at https://bl-ake.github.io/relucent/
Obtaining a Gurobi License
Without a license, Gurobi will only work with a limited feature set. This includes a limit on the number of decision variables in the models it can solve, which limits the size of the networks this code is able to analyze. There are multiple ways to install the software, but we recommend the following steps to those eligible for an academic license:
- Install the Gurobi Python library, for example using
pip install gurobipy - Obtain a Gurobi license (Note: a WLS license will limit the number of concurrent sessions across multiple devices, which can result in slowdowns when using this library on different machines simultaneously.)
- In your Conda environment, run
grbgetkeyfollowed by your license key
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file relucent-0.2.4.tar.gz.
File metadata
- Download URL: relucent-0.2.4.tar.gz
- Upload date:
- Size: 31.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62d3a04eca3feb655fae81c3562399c20d7d0a3dc157f0e8623cdd7561117c82
|
|
| MD5 |
f827273a992e26c11dcaa2e519d5379e
|
|
| BLAKE2b-256 |
74d33f85f3b57aab67a011f84306d1d9aa670b6b418169cbecc5317a534914df
|
Provenance
The following attestation bundles were made for relucent-0.2.4.tar.gz:
Publisher:
publish.yml on bl-ake/relucent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
relucent-0.2.4.tar.gz -
Subject digest:
62d3a04eca3feb655fae81c3562399c20d7d0a3dc157f0e8623cdd7561117c82 - Sigstore transparency entry: 843438055
- Sigstore integration time:
-
Permalink:
bl-ake/relucent@8754e0536d0bf7444efd15c1857ead91321038d4 -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/bl-ake
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8754e0536d0bf7444efd15c1857ead91321038d4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file relucent-0.2.4-py3-none-any.whl.
File metadata
- Download URL: relucent-0.2.4-py3-none-any.whl
- Upload date:
- Size: 34.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88067ee1b98098eee8bb7866cc6e76b2557bed07b47a49f8f4f53a1c1f5c89ee
|
|
| MD5 |
0aca5948a862196a66a498120efb5b2d
|
|
| BLAKE2b-256 |
992e3b64219a3a2082358cf1cec15e8aac88109a575b7044d04a522e1663020f
|
Provenance
The following attestation bundles were made for relucent-0.2.4-py3-none-any.whl:
Publisher:
publish.yml on bl-ake/relucent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
relucent-0.2.4-py3-none-any.whl -
Subject digest:
88067ee1b98098eee8bb7866cc6e76b2557bed07b47a49f8f4f53a1c1f5c89ee - Sigstore transparency entry: 843438076
- Sigstore integration time:
-
Permalink:
bl-ake/relucent@8754e0536d0bf7444efd15c1857ead91321038d4 -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/bl-ake
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8754e0536d0bf7444efd15c1857ead91321038d4 -
Trigger Event:
release
-
Statement type: