mirror of
https://github.com/mrdbourke/pytorch-deep-learning.git
synced 2026-11-27 06:07:09 +00:00
Merge branch 'main' of https://github.com/mrdbourke/pytorch-deep-learning into main
This commit is contained in:
commit
17b3108639
4 files changed
+11
-11
No files matched your search
@@ -697,7 +697,7 @@
|
||||
"\n",
|
||||
"And machine learning models such as neural networks manipulate and seek patterns within tensors.\n",
|
||||
"\n",
|
||||
"But when building machine learning models with PyTorch, it's rare you'll create tenors by hand (like what we've being doing).\n",
|
||||
"But when building machine learning models with PyTorch, it's rare you'll create tensors by hand (like what we've being doing).\n",
|
||||
"\n",
|
||||
"Instead, a machine learning model often starts out with large random tensors of numbers and adjusts these random numbers as it works through data to better represent it.\n",
|
||||
"\n",
|
||||
@@ -1044,7 +1044,7 @@
|
||||
"float_32_tensor = torch.tensor([3.0, 6.0, 9.0],\n",
|
||||
" dtype=None, # defaults to None, which is torch.float32 or whatever datatype is passed\n",
|
||||
" device=None, # defaults to None, which uses the default tensor type\n",
|
||||
" requires_grad=False) # if True, operations perfromed on the tensor are recorded \n",
|
||||
" requires_grad=False) # if True, operations performed on the tensor are recorded \n",
|
||||
"\n",
|
||||
"float_32_tensor.shape, float_32_tensor.dtype, float_32_tensor.device"
|
||||
]
|
||||
|
||||
@@ -956,7 +956,7 @@
|
||||
"| Stochastic Gradient Descent (SGD) optimizer | Classification, regression, many others. | [`torch.optim.SGD()`](https://pytorch.org/docs/stable/generated/torch.optim.SGD.html) |\n",
|
||||
"| Adam Optimizer | Classification, regression, many others. | [`torch.optim.Adam()`](https://pytorch.org/docs/stable/generated/torch.optim.Adam.html) |\n",
|
||||
"| Binary cross entropy loss | Binary classification | [`torch.nn.BCELossWithLogits`](https://pytorch.org/docs/stable/generated/torch.nn.BCEWithLogitsLoss.html) or [`torch.nn.BCELoss`](https://pytorch.org/docs/stable/generated/torch.nn.BCELoss.html) |\n",
|
||||
"| Cross entropy loss | Mutli-class classification | [`torch.nn.CrossEntropyLoss`](https://pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html) |\n",
|
||||
"| Cross entropy loss | Multi-class classification | [`torch.nn.CrossEntropyLoss`](https://pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html) |\n",
|
||||
"| Mean absolute error (MAE) or L1 Loss | Regression | [`torch.nn.L1Loss`](https://pytorch.org/docs/stable/generated/torch.nn.L1Loss.html) | \n",
|
||||
"| Mean squared error (MSE) or L2 Loss | Regression | [`torch.nn.MSELoss`](https://pytorch.org/docs/stable/generated/torch.nn.MSELoss.html#torch.nn.MSELoss) | \n",
|
||||
"\n",
|
||||
@@ -2913,7 +2913,7 @@
|
||||
"id": "f5Ephtx6f1jB"
|
||||
},
|
||||
"source": [
|
||||
"### 8.1 Creating mutli-class classification data\n",
|
||||
"### 8.1 Creating multi-class classification data\n",
|
||||
"\n",
|
||||
"To begin a multi-class classification problem, let's create some multi-class data.\n",
|
||||
"\n",
|
||||
|
||||
@@ -212,7 +212,7 @@
|
||||
"print(\"Pred probs:\")\n",
|
||||
"## Your code here ##\n",
|
||||
"\n",
|
||||
"# Prediction probabilities\n",
|
||||
"# Prediction labels\n",
|
||||
"print(\"Pred labels:\")\n",
|
||||
"## Your code here ##"
|
||||
],
|
||||
|
||||
@@ -630,10 +630,10 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# Let's calculuate the accuracy\n",
|
||||
"# Let's calculate the accuracy\n",
|
||||
"!pip -q install torchmetrics # colab doesn't come with torchmetrics\n",
|
||||
"from torchmetrics import Accuracy\n",
|
||||
"acc_fn = Accuracy().to(device) # send accuracy function to device\n",
|
||||
"acc_fn = Accuracy(task=\"multiclass\", num_classes=2).to(device) # send accuracy function to device\n",
|
||||
"acc_fn"
|
||||
],
|
||||
"metadata": {
|
||||
@@ -649,7 +649,7 @@
|
||||
"output_type": "execute_result",
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Accuracy()"
|
||||
"MulticlassAccuracy()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -1054,10 +1054,10 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# Let's calculuate the accuracy for when we fit our model\n",
|
||||
"# Let's calculate the accuracy for when we fit our model\n",
|
||||
"!pip -q install torchmetrics # colab doesn't come with torchmetrics\n",
|
||||
"from torchmetrics import Accuracy\n",
|
||||
"acc_fn = Accuracy().to(device)\n",
|
||||
"acc_fn = Accuracy(task=\"multiclass\", num_classes=3).to(device) # send accuracy function to device\n",
|
||||
"acc_fn"
|
||||
],
|
||||
"metadata": {
|
||||
@@ -1073,7 +1073,7 @@
|
||||
"output_type": "execute_result",
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Accuracy()"
|
||||
"MulticlassAccuracy()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
|
||||
Reference in new issue
Block a user