NearestNeighbors

public final class NearestNeighbors

Selects the k nearest centers for each point.

Rows of points are assumed to be input points. Rows of centers are assumed to be the list of candidate centers. For each point, the k centers that have least L2 distance to it are computed.

Constants

String OP_NAME The name of this op, as known by TensorFlow core engine

Public Methods

static NearestNeighbors
create(Scope scope, Operand<TFloat32> points, Operand<TFloat32> centers, Operand<TInt64> k)
Factory method to create a class wrapping a new NearestNeighbors operation.
Output<TFloat32>
nearestCenterDistances()
Matrix of shape (n, min(m, k)).
Output<TInt64>
nearestCenterIndices()
Matrix of shape (n, min(m, k)).

Inherited Methods

org.tensorflow.op.RawOp
final boolean
equals(Object obj)
final int
Operation
op()
Return this unit of computation as a single Operation.
final String
boolean
equals(Object arg0)
final Class<?>
getClass()
int
hashCode()
final void
notify()
final void
notifyAll()
String
toString()
final void
wait(long arg0, int arg1)
final void
wait(long arg0)
final void
wait()
org.tensorflow.op.Op
abstract ExecutionEnvironment
env()
Return the execution environment this op was created in.
abstract Operation
op()
Return this unit of computation as a single Operation.

Constants

public static final String OP_NAME

The name of this op, as known by TensorFlow core engine

Constant Value: "NearestNeighbors"

Public Methods

public static NearestNeighbors create (Scope scope, Operand<TFloat32> points, Operand<TFloat32> centers, Operand<TInt64> k)

Factory method to create a class wrapping a new NearestNeighbors operation.

Parameters
scope current scope
points Matrix of shape (n, d). Rows are assumed to be input points.
centers Matrix of shape (m, d). Rows are assumed to be centers.
k Number of nearest centers to return for each point. If k is larger than m, then only m centers are returned.
Returns
  • a new instance of NearestNeighbors

public Output<TFloat32> nearestCenterDistances ()

Matrix of shape (n, min(m, k)). Each row contains the squared L2 distance to the corresponding center in nearest_center_indices.

public Output<TInt64> nearestCenterIndices ()

Matrix of shape (n, min(m, k)). Each row contains the indices of the centers closest to the corresponding point, ordered by increasing distance.