nnconvexity
This package contains the documentation for the nnconvexity Python package. See also the code for the paper containing a demo for using this package.
If you use our code, please cite the paper Tětková, L., Brüsch, T., Dorszewski, T. et al. On convex decision regions in deep network representations. Nat Commun 16, 5419 (2025). https://doi.org/10.1038/s41467-025-60809-y.
We support two ways to compute convexity:
- Euclidean using [nnconvexity.euclidean][]
- graph using [nnconvexity.graph][]
nnconvexity.euclidean.compute_euclidean_convexity(representations, labels, predict_from_middle, layer, n_pairs=5000, n_sampled=10)
Compute Euclidean convexity (in %) for given representations and labels.
| Parameters: |
|
|---|
| Returns: |
|
|---|
nnconvexity.graph.compute_graph_convexity(representations, labels, n_neighbors=10, max_n_paths=5000, n_parallel=1)
Compute graph convexity (in %) for given representations and labels.
| Parameters: |
|
|---|
| Returns: |
|
|---|