Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/add no_grad() for batch_predict() #340

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions fsrs4anki_optimizer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# FSRS4Anki v3.26.0 Optimizer\n",
"# FSRS4Anki v3.26.1 Optimizer\n",
"\n",
"[![open in colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-spaced-repetition/fsrs4anki/blob/v3.26.0/fsrs4anki_optimizer.ipynb)\n",
"[![open in colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-spaced-repetition/fsrs4anki/blob/v3.26.1/fsrs4anki_optimizer.ipynb)\n",
"\n",
"↑ Click the above button to open the optimizer on Google Colab.\n",
"\n",
Expand Down Expand Up @@ -106,7 +106,7 @@
}
],
"source": [
"%pip install -q fsrs4anki_optimizer==3.26.0\n",
"%pip install -q fsrs4anki_optimizer==3.26.1\n",
"# for local development\n",
"# import os\n",
"# import sys\n",
Expand Down
7 changes: 4 additions & 3 deletions package/fsrs4anki_optimizer/fsrs4anki_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,10 @@ def predict(self, t_history: str, r_history: str):

def batch_predict(self, dataset):
fast_dataset = RevlogDataset(dataset)
outputs, _ = self.model(fast_dataset.x_train.transpose(0, 1))
stabilities, difficulties = outputs[fast_dataset.seq_len-1, torch.arange(len(fast_dataset))].transpose(0, 1)
return stabilities.tolist(), difficulties.tolist()
with torch.no_grad():
outputs, _ = self.model(fast_dataset.x_train.transpose(0, 1))
stabilities, difficulties = outputs[fast_dataset.seq_len-1, torch.arange(len(fast_dataset))].transpose(0, 1)
return stabilities.tolist(), difficulties.tolist()

"""Used to store all the results from FSRS related functions"""
class Optimizer:
Expand Down
2 changes: 1 addition & 1 deletion package/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 = "fsrs4anki_optimizer"
version = "3.26.0"
version = "3.26.1"
readme = "README.md"
dependencies = [
"matplotlib>=3.7.0",
Expand Down