update fundamentals

This commit is contained in:
Daniel Bourke committed 2023-03-09 15:14:22 +10:00
1 parent 033704af00
commit 08eff08770
1 file changed
+19 -19
+19 -19
View File
@@ -111,7 +111,7 @@
{
"data": {
"text/plain": [
"'1.12.1+cu113'"
"'1.13.1+cu116'"
]
},
"execution_count": 1,
@@ -728,9 +728,9 @@
{
"data": {
"text/plain": [
"(tensor([[0.3554, 0.3453, 0.3330, 0.2967],\n",
" [0.1251, 0.0410, 0.0230, 0.8989],\n",
" [0.2398, 0.1786, 0.7962, 0.1559]]),\n",
"(tensor([[0.6541, 0.4807, 0.2162, 0.6168],\n",
" [0.4428, 0.6608, 0.6194, 0.8620],\n",
" [0.2795, 0.6055, 0.4958, 0.5483]]),\n",
" torch.float32)"
]
},
@@ -907,7 +907,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_32574/193451495.py:2: UserWarning: torch.range is deprecated and will be removed in a future release because its behavior is inconsistent with Python's range builtin. Instead, use torch.arange, which produces values in [start, end).\n",
"/tmp/ipykernel_3695928/193451495.py:2: UserWarning: torch.range is deprecated and will be removed in a future release because its behavior is inconsistent with Python's range builtin. Instead, use torch.arange, which produces values in [start, end).\n",
" zero_to_ten_deprecated = torch.range(0, 10) # Note: this may return an error in the future\n"
]
},
@@ -1128,9 +1128,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"tensor([[0.2423, 0.6624, 0.3201, 0.3021],\n",
" [0.7961, 0.9539, 0.0791, 0.8537],\n",
" [0.3491, 0.6429, 0.8308, 0.4690]])\n",
"tensor([[0.4688, 0.0055, 0.8551, 0.0646],\n",
" [0.6538, 0.5157, 0.4071, 0.2109],\n",
" [0.9960, 0.3061, 0.9369, 0.7008]])\n",
"Shape of tensor: torch.Size([3, 4])\n",
"Datatype of tensor: torch.float32\n",
"Device tensor is stored on: cpu\n"
@@ -1629,8 +1629,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 97 µs, sys: 100 µs, total: 197 µs\n",
"Wall time: 265 µs\n"
"CPU times: user 773 µs, sys: 0 ns, total: 773 µs\n",
"Wall time: 499 µs\n"
]
},
{
@@ -1669,8 +1669,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 46 µs, sys: 0 ns, total: 46 µs\n",
"Wall time: 34.6 µs\n"
"CPU times: user 146 µs, sys: 83 µs, total: 229 µs\n",
"Wall time: 171 µs\n"
]
},
{
@@ -1719,7 +1719,7 @@
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)",
"Input \u001b[0;32mIn [37]\u001b[0m, in \u001b[0;36m<cell line: 10>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 2\u001b[0m tensor_A \u001b[38;5;241m=\u001b[39m torch\u001b[38;5;241m.\u001b[39mtensor([[\u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m2\u001b[39m],\n\u001b[1;32m 3\u001b[0m [\u001b[38;5;241m3\u001b[39m, \u001b[38;5;241m4\u001b[39m],\n\u001b[1;32m 4\u001b[0m [\u001b[38;5;241m5\u001b[39m, \u001b[38;5;241m6\u001b[39m]], dtype\u001b[38;5;241m=\u001b[39mtorch\u001b[38;5;241m.\u001b[39mfloat32)\n\u001b[1;32m 6\u001b[0m tensor_B \u001b[38;5;241m=\u001b[39m torch\u001b[38;5;241m.\u001b[39mtensor([[\u001b[38;5;241m7\u001b[39m, \u001b[38;5;241m10\u001b[39m],\n\u001b[1;32m 7\u001b[0m [\u001b[38;5;241m8\u001b[39m, \u001b[38;5;241m11\u001b[39m], \n\u001b[1;32m 8\u001b[0m [\u001b[38;5;241m9\u001b[39m, \u001b[38;5;241m12\u001b[39m]], dtype\u001b[38;5;241m=\u001b[39mtorch\u001b[38;5;241m.\u001b[39mfloat32)\n\u001b[0;32m---> 10\u001b[0m \u001b[43mtorch\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmatmul\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtensor_A\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtensor_B\u001b[49m\u001b[43m)\u001b[49m\n",
"\u001b[1;32m/home/daniel/code/pytorch/pytorch-course/pytorch-deep-learning/00_pytorch_fundamentals.ipynb Cell 75\u001b[0m in \u001b[0;36m<cell line: 10>\u001b[0;34m()\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2B7b22686f73744e616d65223a22544954414e2d525458227d/home/daniel/code/pytorch/pytorch-course/pytorch-deep-learning/00_pytorch_fundamentals.ipynb#Y134sdnNjb2RlLXJlbW90ZQ%3D%3D?line=1'>2</a>\u001b[0m tensor_A \u001b[39m=\u001b[39m torch\u001b[39m.\u001b[39mtensor([[\u001b[39m1\u001b[39m, \u001b[39m2\u001b[39m],\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2B7b22686f73744e616d65223a22544954414e2d525458227d/home/daniel/code/pytorch/pytorch-course/pytorch-deep-learning/00_pytorch_fundamentals.ipynb#Y134sdnNjb2RlLXJlbW90ZQ%3D%3D?line=2'>3</a>\u001b[0m [\u001b[39m3\u001b[39m, \u001b[39m4\u001b[39m],\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2B7b22686f73744e616d65223a22544954414e2d525458227d/home/daniel/code/pytorch/pytorch-course/pytorch-deep-learning/00_pytorch_fundamentals.ipynb#Y134sdnNjb2RlLXJlbW90ZQ%3D%3D?line=3'>4</a>\u001b[0m [\u001b[39m5\u001b[39m, \u001b[39m6\u001b[39m]], dtype\u001b[39m=\u001b[39mtorch\u001b[39m.\u001b[39mfloat32)\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2B7b22686f73744e616d65223a22544954414e2d525458227d/home/daniel/code/pytorch/pytorch-course/pytorch-deep-learning/00_pytorch_fundamentals.ipynb#Y134sdnNjb2RlLXJlbW90ZQ%3D%3D?line=5'>6</a>\u001b[0m tensor_B \u001b[39m=\u001b[39m torch\u001b[39m.\u001b[39mtensor([[\u001b[39m7\u001b[39m, \u001b[39m10\u001b[39m],\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2B7b22686f73744e616d65223a22544954414e2d525458227d/home/daniel/code/pytorch/pytorch-course/pytorch-deep-learning/00_pytorch_fundamentals.ipynb#Y134sdnNjb2RlLXJlbW90ZQ%3D%3D?line=6'>7</a>\u001b[0m [\u001b[39m8\u001b[39m, \u001b[39m11\u001b[39m], \n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2B7b22686f73744e616d65223a22544954414e2d525458227d/home/daniel/code/pytorch/pytorch-course/pytorch-deep-learning/00_pytorch_fundamentals.ipynb#Y134sdnNjb2RlLXJlbW90ZQ%3D%3D?line=7'>8</a>\u001b[0m [\u001b[39m9\u001b[39m, \u001b[39m12\u001b[39m]], dtype\u001b[39m=\u001b[39mtorch\u001b[39m.\u001b[39mfloat32)\n\u001b[0;32m---> <a href='vscode-notebook-cell://ssh-remote%2B7b22686f73744e616d65223a22544954414e2d525458227d/home/daniel/code/pytorch/pytorch-course/pytorch-deep-learning/00_pytorch_fundamentals.ipynb#Y134sdnNjb2RlLXJlbW90ZQ%3D%3D?line=9'>10</a>\u001b[0m torch\u001b[39m.\u001b[39;49mmatmul(tensor_A, tensor_B)\n",
"\u001b[0;31mRuntimeError\u001b[0m: mat1 and mat2 shapes cannot be multiplied (3x2 and 3x2)"
]
}
@@ -3288,7 +3288,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Thu Nov 10 16:06:00 2022 \n",
"Sat Jan 21 08:34:23 2023 \n",
"+-----------------------------------------------------------------------------+\n",
"| NVIDIA-SMI 515.48.07 Driver Version: 515.48.07 CUDA Version: 11.7 |\n",
"|-------------------------------+----------------------+----------------------+\n",
@@ -3297,7 +3297,7 @@
"| | | MIG M. |\n",
"|===============================+======================+======================|\n",
"| 0 NVIDIA TITAN RTX On | 00000000:01:00.0 Off | N/A |\n",
"| 41% 30C P8 6W / 280W | 206MiB / 24576MiB | 0% Default |\n",
"| 40% 30C P8 7W / 280W | 177MiB / 24576MiB | 0% Default |\n",
"| | | N/A |\n",
"+-------------------------------+----------------------+----------------------+\n",
" \n",
@@ -3306,9 +3306,9 @@
"| GPU GI CI PID Type Process name GPU Memory |\n",
"| ID ID Usage |\n",
"|=============================================================================|\n",
"| 0 N/A N/A 1081 G /usr/lib/xorg/Xorg 53MiB |\n",
"| 0 N/A N/A 1599 G /usr/lib/xorg/Xorg 95MiB |\n",
"| 0 N/A N/A 1726 G /usr/bin/gnome-shell 44MiB |\n",
"| 0 N/A N/A 1061 G /usr/lib/xorg/Xorg 53MiB |\n",
"| 0 N/A N/A 2671131 G /usr/lib/xorg/Xorg 97MiB |\n",
"| 0 N/A N/A 2671256 G /usr/bin/gnome-shell 9MiB |\n",
"+-----------------------------------------------------------------------------+\n"
]
}
@@ -3612,7 +3612,7 @@
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"Input \u001b[0;32mIn [75]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# If tensor is on GPU, can't transform it to NumPy (this will error)\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[43mtensor_on_gpu\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mnumpy\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
"\u001b[1;32m/home/daniel/code/pytorch/pytorch-course/pytorch-deep-learning/00_pytorch_fundamentals.ipynb Cell 157\u001b[0m in \u001b[0;36m<cell line: 2>\u001b[0;34m()\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2B7b22686f73744e616d65223a22544954414e2d525458227d/home/daniel/code/pytorch/pytorch-course/pytorch-deep-learning/00_pytorch_fundamentals.ipynb#Y312sdnNjb2RlLXJlbW90ZQ%3D%3D?line=0'>1</a>\u001b[0m \u001b[39m# If tensor is on GPU, can't transform it to NumPy (this will error)\u001b[39;00m\n\u001b[0;32m----> <a href='vscode-notebook-cell://ssh-remote%2B7b22686f73744e616d65223a22544954414e2d525458227d/home/daniel/code/pytorch/pytorch-course/pytorch-deep-learning/00_pytorch_fundamentals.ipynb#Y312sdnNjb2RlLXJlbW90ZQ%3D%3D?line=1'>2</a>\u001b[0m tensor_on_gpu\u001b[39m.\u001b[39;49mnumpy()\n",
"\u001b[0;31mTypeError\u001b[0m: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first."
]
}