From 3ba51abf53542b8083ff12043c94bf8b28e7a91a Mon Sep 17 00:00:00 2001 From: rasbt Date: Wed, 19 Jun 2024 19:47:31 -0500 Subject: [PATCH] consistency --- ch07/01_main-chapter-code/ch07.ipynb | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ch07/01_main-chapter-code/ch07.ipynb b/ch07/01_main-chapter-code/ch07.ipynb index 2ed5b9d..a36951f 100644 --- a/ch07/01_main-chapter-code/ch07.ipynb +++ b/ch07/01_main-chapter-code/ch07.ipynb @@ -1108,8 +1108,6 @@ } ], "source": [ - "from functools import partial\n", - "\n", "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n", "\n", "# If you have a Mac with Apple Silicon chip, you can uncomment the next lines of code\n", @@ -1120,7 +1118,17 @@ "# if torch.backends.mps.is_available():\n", "# device = torch.device(\"mps\")\n", "\n", - "print(\"Device:\", device)\n", + "print(\"Device:\", device)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4e47fb30-c2c6-4e6d-a64c-76cc65be4a2c", + "metadata": {}, + "outputs": [], + "source": [ + "from functools import partial\n", "\n", "customized_collate_fn = partial(custom_collate_fn, device=device, allowed_max_length=1024)" ] @@ -2150,7 +2158,8 @@ "base_uri": "https://localhost:8080/" }, "id": "8cBU0iHmVfOI", - "outputId": "860a2d06-2d0e-4ae8-943d-dd12d299eed9" + "outputId": "860a2d06-2d0e-4ae8-943d-dd12d299eed9", + "scrolled": true }, "outputs": [ { @@ -2164,7 +2173,7 @@ "source": [ "import re\n", "\n", - "model.cpu()\n", + "\n", "file_name = f\"{re.sub(r'[ ()]', '', CHOOSE_MODEL) }-sft.pth\"\n", "torch.save(model.state_dict(), file_name)\n", "print(f\"Model saved as {file_name}\")\n", @@ -2728,7 +2737,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.11.4" } }, "nbformat": 4,