Skip to content

Commit

Permalink
No need for try and and catch, just error out
Browse files Browse the repository at this point in the history
  • Loading branch information
metric-space committed Jul 10, 2024
1 parent a38a292 commit fab765b
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions mergekit/scripts/ABM/extract_permutation_matrices.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import pdb
import sys
from collections import defaultdict

Expand Down Expand Up @@ -31,14 +30,11 @@ def match_tensors_permute(
device = correlation_matrix.device

mats = [torch.eye(Om, device=device)]
try:
corr_submatrix = correlation_matrix[:Om, Om:].cpu().numpy()
if absval:
corr_submatrix = np.absolute(corr_submatrix)
_, col_ind = scipy.optimize.linear_sum_assignment(corr_submatrix, maximize=True)
except Exception as e:
print(e)
pdb.set_trace()

corr_submatrix = correlation_matrix[:Om, Om:].cpu().numpy()
if absval:
corr_submatrix = np.absolute(corr_submatrix)
_, col_ind = scipy.optimize.linear_sum_assignment(corr_submatrix, maximize=True)

new_mat = torch.eye(Om, device=device)[torch.tensor(col_ind).long().to(device)]
mats.append(new_mat.T)
Expand Down

0 comments on commit fab765b

Please sign in to comment.