Skip to content

Commit

Permalink
prototypes: small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoninPoche committed Sep 25, 2024
1 parent 222527a commit c8a0abe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion xplique/example_based/search_methods/proto_dash_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def _update_selection_weights(self,
# use w* = K^-1 * u as the optimal weights
# (|S|,)
selection_weights = tf.linalg.matvec(K_inv, u)
selection_weights = tf.abs(selection_weights)
selection_weights = tf.maximum(selection_weights, 0)

# update the weights
self.prototypes_weights[:nb_selected].assign(selection_weights)
Expand Down
4 changes: 2 additions & 2 deletions xplique/example_based/search_methods/proto_greedy_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ def _compute_batch_objectives(self,
K_inv = tf.linalg.inv(K + ProtoGreedySearch.EPSILON * tf.eye(K.shape[-1]))

# (bc, |S| + 1) - w* = K^-1 mu_p
objectives_weights = tf.abs(tf.einsum("bsp,bp->bs",
K_inv, candidates_selection_kernel_col_means))
objectives_weights = tf.einsum("bsp,bp->bs", K_inv, candidates_selection_kernel_col_means)
objectives_weights = tf.maximum(objectives_weights, 0)

# (bc,) - (w*^T mu_p)
weights_mu_p = tf.einsum("bp,bp->b",
Expand Down

0 comments on commit c8a0abe

Please sign in to comment.