Skip to content

ONNX from nearest_neighbors produces no distance effect when keep_distances=True #1214

@yishiouchen

Description

@yishiouchen

This is an issue about the onnx_nearest_neighbors_indices_k() function in nearest_neighbours.py when the keep_distances option is true.

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.

Here is my suggested fix: https://github.com/onnx/sklearn-onnx/pull/1212/files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions