From f95e0a910db51f51588dd563fa740da13c3872d1 Mon Sep 17 00:00:00 2001 From: rasbt Date: Sun, 2 Jun 2024 20:41:34 -0500 Subject: [PATCH] easier to read tensor formatting --- appendix-A/01_main-chapter-code/code-part1.ipynb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/appendix-A/01_main-chapter-code/code-part1.ipynb b/appendix-A/01_main-chapter-code/code-part1.ipynb index 98d7f7b..535e0b5 100644 --- a/appendix-A/01_main-chapter-code/code-part1.ipynb +++ b/appendix-A/01_main-chapter-code/code-part1.ipynb @@ -137,13 +137,16 @@ "tensor1d = torch.tensor([1, 2, 3])\n", "\n", "# create a 2D tensor from a nested Python list\n", - "tensor2d = torch.tensor([[1, 2], [3, 4]])\n", + "tensor2d = torch.tensor([[1, 2], \n", + " [3, 4]])\n", "\n", "# create a 3D tensor from a nested Python list\n", - "tensor3d_1 = torch.tensor([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])\n", + "tensor3d_1 = torch.tensor([[[1, 2], [3, 4]], \n", + " [[5, 6], [7, 8]]])\n", "\n", "# create a 3D tensor from NumPy array\n", - "ary3d = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])\n", + "ary3d = np.array([[[1, 2], [3, 4]], \n", + " [[5, 6], [7, 8]]])\n", "tensor3d_2 = torch.tensor(ary3d) # Copies NumPy array\n", "tensor3d_3 = torch.from_numpy(ary3d) # Shares memory with NumPy array" ] @@ -285,7 +288,8 @@ } ], "source": [ - "tensor2d = torch.tensor([[1, 2, 3], [4, 5, 6]])\n", + "tensor2d = torch.tensor([[1, 2, 3], \n", + " [4, 5, 6]])\n", "tensor2d" ] }, @@ -1336,7 +1340,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.10.6" } }, "nbformat": 4,