Skip to content

Commit

Permalink
Fix/sort by real seq_len && improve performance (#146)
Browse files Browse the repository at this point in the history
* Fix/sort by real seq_len

* bump version
  • Loading branch information
L-M-Sherlock authored Oct 29, 2024
1 parent cb4ed78 commit 566620e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "FSRS-Optimizer"
version = "5.2.2"
version = "5.2.3"
readme = "README.md"
dependencies = [
"matplotlib>=3.7.0",
Expand Down
6 changes: 4 additions & 2 deletions src/fsrs_optimizer/fsrs_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,11 @@ def __init__(
):
if dataframe.empty:
raise ValueError("Training data is inadequate.")
dataframe["seq_len"] = dataframe["tensor"].map(len)
dataframe = dataframe[dataframe["seq_len"] <= max_seq_len]
if sort_by_length:
dataframe = dataframe.sort_values(by=["i"])
dataframe = dataframe[dataframe["tensor"].map(len) <= max_seq_len]
dataframe = dataframe.sort_values(by="seq_len")
del dataframe["seq_len"]
self.x_train = pad_sequence(
dataframe["tensor"].to_list(), batch_first=True, padding_value=0
)
Expand Down

0 comments on commit 566620e

Please sign in to comment.