Skip to content

Commit

Permalink
Fix bug of specifying weight IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
vbkaisetsu committed Sep 21, 2022
1 parent df29757 commit bbc43c8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/trainer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ impl Trainer {
let unigram_weight_indices = loss_function_used.unigram_weight_indices;
let bigram_weight_indices = loss_function_used.bigram_weight_indices;

// Removes zero features
// Removes zero weighted features
let mut weight_id_map = HashMap::new();
let mut new_weights = vec![0.0];
let mut new_weights = vec![];
for (i, w) in weights.into_iter().enumerate() {
if w.abs() < f64::EPSILON {
continue;
Expand All @@ -468,7 +468,7 @@ impl Trainer {
new_unigram_weight_indices.push(old_idx.and_then(|old_idx| {
weight_id_map
.get(&(old_idx.get() - 1))
.and_then(|&new_idx| NonZeroU32::new(new_idx))
.and_then(|&new_idx| NonZeroU32::new(new_idx + 1))
}));
}
let mut new_bigram_weight_indices = vec![];
Expand Down

0 comments on commit bbc43c8

Please sign in to comment.