Skip to content

Commit 6f3b4ef

Browse files
author
nnethercott
committed
decrease iteration steps in two_means
when this value is large increasing n_trees yields no benefits. suggested value is "good enough" for the time being; e.g. performance is better than main branch but its not a global optimum
1 parent 9912f73 commit 6f3b4ef

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/distance/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ fn two_means<D: Distance, R: Rng>(
129129
// points to either one of them. We weight each centroid by the number of points
130130
// assigned to it, so to balance it.
131131

132-
const ITERATION_STEPS: usize = 200;
132+
#[allow(non_snake_case)]
133+
let ITERATION_STEPS: usize = 10.min(leafs.len() as usize);
133134

134135
let [leaf_p, leaf_q] = leafs.choose_two(rng)?.unwrap();
135136
let (mut leaf_p, mut leaf_q) = (leaf_p.into_owned(), leaf_q.into_owned());
@@ -179,7 +180,8 @@ pub fn two_means_binary_quantized<D: Distance, NonBqDist: Distance, R: Rng>(
179180
// to move, we need to store it as f32. This requires us to convert every binary quantized
180181
// vectors to f32 vectors, but the recall suffers too much if we don't do it.
181182

182-
const ITERATION_STEPS: usize = 200;
183+
#[allow(non_snake_case)]
184+
let ITERATION_STEPS: usize = 10.min(leafs.len() as usize);
183185

184186
let [leaf_p, leaf_q] = leafs.choose_two(rng)?.unwrap();
185187
let mut leaf_p: Leaf<'static, NonBqDist> = new_leaf(leaf_p.vector.to_vec());

0 commit comments

Comments
 (0)