Skip to content

Commit 332e07f

Browse files
authored
Update nearest_neighbours.py for weights=distance
The Mul operator created in line 141 converts distances (node[0]) from OnnxTopK_11 to negative values. The Mul operator is followed by a Max operator, which turns any negative value to 1e-6, so distances lose their effect in the downstream operation. I think this Mul operator should be removed, and node[0] can be connected to the Max operator directly. Signed-off-by: yishiouchen <[email protected]>
1 parent 153328a commit 332e07f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

skl2onnx/operator_converters/nearest_neighbours.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def onnx_nearest_neighbors_indices_k(
138138
if keep_distances:
139139
return (
140140
node[1],
141-
OnnxMul(node[0], np.array([-1], dtype=dtype), op_version=op_version),
141+
node[0]
142142
)
143143
if keep_distances:
144144
return (node[1], node[0])

0 commit comments

Comments
 (0)