Пример #1
0
 def testNearest1(self):
     with self.cached_session():
         [indices, distances
          ] = clustering_ops.nearest_neighbors(self._points, self._centers,
                                               1)
         self.assertAllClose(indices, [[0], [0], [1], [4]])
         self.assertAllClose(distances, [[0.], [5.], [1.], [0.]])
Пример #2
0
 def testNearest5(self):
     with self.cached_session():
         [indices, distances
          ] = clustering_ops.nearest_neighbors(self._points, self._centers,
                                               5)
         self.assertAllClose(
             indices, self._expected_nearest_neighbor_indices[:, 0:5])
         self.assertAllClose(
             distances,
             self._expected_nearest_neighbor_squared_distances[:, 0:5])
 def testNearest5(self):
   with self.cached_session():
     [indices, distances] = clustering_ops.nearest_neighbors(self._points,
                                                             self._centers, 5)
     self.assertAllClose(
         indices,
         self._expected_nearest_neighbor_indices[:, 0:5])
     self.assertAllClose(
         distances,
         self._expected_nearest_neighbor_squared_distances[:, 0:5])
 def testNearest2(self):
   with self.cached_session():
     [indices, distances] = clustering_ops.nearest_neighbors(self._points,
                                                             self._centers, 2)
     self.assertAllClose(indices, [[0, 1], [0, 1], [1, 0], [4, 3]])
     self.assertAllClose(distances, [[0., 2.], [5., 5.], [1., 5.], [0., 2.]])