Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion error_parity/classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,17 @@ def find_weights_given_two_points(
f"should be 1!"
)

if not all(np.isclose(target_point, all_weights @ all_points)):
if not all(np.isclose(target_point, all_weights @ all_points, atol=1e-5)):
raise RuntimeError(
f"Triangulation of target point failed. "
f"Target was {target_point}; got {all_weights @ all_points}."
)

if (all_weights < 0).any():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you ever encounter a scenario where any weights were negative? And if so, could you post a code example?

all_weights = np.asarray(all_weights)
x_max = np.amax(all_weights, axis=0, keepdims=True)
exp_x_shifted = np.exp(all_weights - x_max)
all_weights = exp_x_shifted / np.sum(exp_x_shifted, axis=0, keepdims=True)

return all_weights, all_points

Expand Down