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 6a4dc28 commit 72e45b8
Show file tree
Hide file tree
Showing 2 changed files with 17 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
19 changes: 16 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,26 @@ 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,
}.elem()
]))
})
.collect();

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

0 comments on commit 72e45b8

Please sign in to comment.