Skip to content

Commit

Permalink
Remove label, as it duplicates existing data
Browse files Browse the repository at this point in the history
  • Loading branch information
dae committed Aug 21, 2023
1 parent a9e1fd5 commit 682c503
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
9 changes: 1 addition & 8 deletions src/convertor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,7 @@ fn convert_to_fsrs_item(
})
.collect_vec();

let last = entries.last().unwrap();
Some(FSRSItem {
reviews,
label: match last.button_chosen {
1 => 0.0,
2 | 3 | 4 | _ => 1.0,
},
})
Some(FSRSItem { reviews })
}

pub fn anki_to_fsrs() -> Vec<FSRSItem> {
Expand Down
24 changes: 21 additions & 3 deletions src/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use crate::convertor::anki_to_fsrs;
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct FSRSItem {
pub reviews: Vec<FSRSReview>,
pub label: f32,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
Expand Down Expand Up @@ -69,12 +68,31 @@ impl<B: Backend> Batcher<FSRSItem, FSRSBatch<B>> for FSRSBatcher<B> {

let delta_ts = items
.iter()
.map(|item| Tensor::<B, 1, Float>::from_data(Data::from([item.reviews.last().unwrap().delta_t.elem()])))
.map(|item| {
Tensor::<B, 1, Float>::from_data(Data::from([item
.reviews
.last()
.unwrap()
.delta_t
.elem()]))
})
.collect();

let labels = items
.iter()
.map(|item| Tensor::<B, 1, Int>::from_data(Data::from([item.label.elem()])))
.map(|item| {
Tensor::<B, 1, Int>::from_data(Data::from([
match item.reviews.last().unwrap().rating {
1 => 0.0,
2 | 3 | 4 => 1.0,
_ => {
// invalid value, assume it's good
1.0
}
}
.elem(),
]))
})
.collect();

let t_historys = Tensor::cat(t_historys, 0)
Expand Down

0 comments on commit 682c503

Please sign in to comment.