Skip to content

Commit 68b5bfd

Browse files
committed
fixed with livelossplot change
1 parent 0bd128a commit 68b5bfd

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

3 Linear regression.ipynb

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"cells": [
33
{
4+
"attachments": {},
45
"cell_type": "markdown",
56
"metadata": {},
67
"source": [
78
"# Thinking in tensors, writing in PyTorch\n",
89
"\n",
9-
"A hands-on course by [Piotr Migdał](https://p.migdal.pl) (2019).\n",
10+
"A hands-on course by [Piotr Migdał](https://p.migdal.pl) (2019-2022).\n",
1011
"This notebook prepared by [Weronika Ormaniec](https://github.com/werkaaa) and Piotr Migdał.\n",
1112
"\n",
1213
"## Notebook 3: Linear regression\n",
@@ -30,15 +31,6 @@
3031
"In Python we typically use [LinearRegression from scikit-learn](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html). Here we use PyTorch to show everything step-by-step. Moreover, linear regression is a building block of any regression with deep learning - so it is good to understand it well!"
3132
]
3233
},
33-
{
34-
"cell_type": "code",
35-
"execution_count": null,
36-
"metadata": {},
37-
"outputs": [],
38-
"source": [
39-
"!pip install --quiet 'livelossplot<0.5'"
40-
]
41-
},
4234
{
4335
"cell_type": "code",
4436
"execution_count": null,
@@ -53,6 +45,7 @@
5345
"import torch.nn as nn\n",
5446
"\n",
5547
"from livelossplot import PlotLosses\n",
48+
"from livelossplot.outputs import MatplotlibPlot\n",
5649
"from ipywidgets import interact, fixed"
5750
]
5851
},
@@ -144,8 +137,8 @@
144137
"metadata": {},
145138
"outputs": [],
146139
"source": [
147-
"X = np.log(data['BodyWeight(kg)'])\n",
148-
"Y = np.log(data['BrainWeight(kg)'])"
140+
"X = np.log(data['BodyWeight(kg)']).astype('float32')\n",
141+
"Y = np.log(data['BrainWeight(kg)']).astype('float32')"
149142
]
150143
},
151144
{
@@ -394,7 +387,7 @@
394387
" plt.title(\"Prediction\")\n",
395388
" plt.legend(loc='lower right')\n",
396389
" \n",
397-
" liveloss = PlotLosses(extra_plots=[extra_plot], plot_extrema=False)\n",
390+
" liveloss = PlotLosses()\n",
398391
" \n",
399392
" for i in range(num_epochs):\n",
400393
" A -= learning_rate * dL_da(A, B, X, Y)\n",
@@ -586,7 +579,7 @@
586579
" plt.title(\"Prediction\")\n",
587580
" plt.legend(loc='lower right')\n",
588581
" \n",
589-
" liveloss = PlotLosses(extra_plots=[extra_plot], plot_extrema=False)\n",
582+
" liveloss = PlotLosses()\n",
590583
"\n",
591584
" for epoch in range(num_epochs):\n",
592585
" \n",
@@ -751,11 +744,16 @@
751744
"![https://imgs.xkcd.com/comics/extrapolating.png](https://imgs.xkcd.com/comics/extrapolating.png)\n",
752745
"\n"
753746
]
747+
},
748+
{
749+
"cell_type": "markdown",
750+
"metadata": {},
751+
"source": []
754752
}
755753
],
756754
"metadata": {
757755
"kernelspec": {
758-
"display_name": "Python [default]",
756+
"display_name": "pytorch-macos-m1-gpu",
759757
"language": "python",
760758
"name": "python3"
761759
},
@@ -769,7 +767,7 @@
769767
"name": "python",
770768
"nbconvert_exporter": "python",
771769
"pygments_lexer": "ipython3",
772-
"version": "3.5.4"
770+
"version": "3.9.13"
773771
},
774772
"notify_time": "30",
775773
"toc": {
@@ -813,6 +811,11 @@
813811
"_Feature"
814812
],
815813
"window_display": false
814+
},
815+
"vscode": {
816+
"interpreter": {
817+
"hash": "032715a8d60757555a2623145b534a689e8b5634c5398e8bbec1014c4a8ede12"
818+
}
816819
}
817820
},
818821
"nbformat": 4,

0 commit comments

Comments
 (0)