Skip to content

Kpnn2Error

Bases: Exception

User-facing failure from the public kpnn2 API.

Raised for invalid edgelists, illegal LayeredSpec operations, bad MaskedLinear masks, saved activations that do not match the hop they are gathered for, input or attribution tensors that do not match the spec, and invalid attribution aggregation calls.

Examples:

>>> import pandas as pd
>>> import kpnn2
>>> edgelist = pd.DataFrame(
...     {
...         "source": ["A"],
...         "target": ["A"],
...     }
... )
>>> kpnn2.parse_layered(edgelist)
Traceback (most recent call last):
...
Kpnn2Error: Edgelist contains 1 self-loop(s): A. ...