Replace handson-ml2 with handson-ml3, and fix figure chapter numbers

main
Aurélien Geron 2021-11-23 15:42:16 +13:00
parent e38983d595
commit 5bb0366125
23 changed files with 137 additions and 137 deletions

View File

@ -10,9 +10,9 @@ assignees: ''
Thanks for helping us improve this project!
**Before you create this issue**
Please make sure you are using the latest updated code and libraries: see https://github.com/ageron/handson-ml2/blob/master/INSTALL.md#update-this-project-and-its-libraries
Please make sure you are using the latest updated code and libraries: see https://github.com/ageron/handson-ml3/blob/main/INSTALL.md#update-this-project-and-its-libraries
Also please make sure to read the FAQ (https://github.com/ageron/handson-ml2#faq) and search for existing issues (both open and closed), as your question may already have been answered: https://github.com/ageron/handson-ml2/issues
Also please make sure to read the FAQ (https://github.com/ageron/handson-ml3#faq) and search for existing issues (both open and closed), as your question may already have been answered: https://github.com/ageron/handson-ml3/issues
**Describe the bug**
Please provide a clear and concise description of what the bug is, and specify the notebook name and the cell number at which the problem occurs (or the chapter and page in the book).

View File

@ -10,9 +10,9 @@ assignees: ''
Thanks for helping us improve this project!
**Before you create this issue**
Please make sure you are using the latest updated code and libraries: see https://github.com/ageron/handson-ml2/blob/master/INSTALL.md#update-this-project-and-its-libraries
Please make sure you are using the latest updated code and libraries: see https://github.com/ageron/handson-ml3/blob/main/INSTALL.md#update-this-project-and-its-libraries
Also please make sure to read the FAQ (https://github.com/ageron/handson-ml2#faq) and search for existing issues (both open and closed), as your question may already have been answered: https://github.com/ageron/handson-ml2/issues
Also please make sure to read the FAQ (https://github.com/ageron/handson-ml3#faq) and search for existing issues (both open and closed), as your question may already have been answered: https://github.com/ageron/handson-ml3/issues
**Describe what is unclear to you**
Please provide a clear and concise description of what the problem is, and specify the notebook name and the cell number at which the problem occurs (or the chapter and page in the book).

View File

@ -10,9 +10,9 @@ assignees: ''
Thanks for helping us improve this project!
**Before you create this issue**
Please make sure you are using the latest updated code and libraries: see https://github.com/ageron/handson-ml2/blob/master/INSTALL.md#update-this-project-and-its-libraries
Please make sure you are using the latest updated code and libraries: see https://github.com/ageron/handson-ml3/blob/main/INSTALL.md#update-this-project-and-its-libraries
Also please make sure to read the FAQ (https://github.com/ageron/handson-ml2#faq) and search for existing issues (both open and closed), as your question may already have been answered: https://github.com/ageron/handson-ml2/issues
Also please make sure to read the FAQ (https://github.com/ageron/handson-ml3#faq) and search for existing issues (both open and closed), as your question may already have been answered: https://github.com/ageron/handson-ml3/issues
**Is your feature request related to a problem? Please describe.**
Please indicate the notebook name and cell number where the problem occurs (or the chapter and page number in the book), and provide a clear and concise description of what the problem is. Ex. In chapter 1, cells 200-220, I think the code could be clearer [...]

View File

@ -17,10 +17,10 @@
"source": [
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml2/blob/master/01_the_machine_learning_landscape.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml3/blob/main/01_the_machine_learning_landscape.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml2/blob/master/01_the_machine_learning_landscape.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml3/blob/main/01_the_machine_learning_landscape.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" </td>\n",
"</table>"
]
@ -127,7 +127,7 @@
"datapath = Path() / \"datasets\" / \"lifesat\"\n",
"datapath.mkdir(parents=True, exist_ok=True)\n",
"\n",
"root = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"\n",
"root = \"https://raw.githubusercontent.com/ageron/handson-ml3/main/\"\n",
"filename = \"lifesat.csv\"\n",
"if not (datapath / filename).is_file():\n",
" print(\"Downloading\", filename)\n",

View File

@ -20,10 +20,10 @@
"source": [
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml2/blob/master/02_end_to_end_machine_learning_project.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml3/blob/main/02_end_to_end_machine_learning_project.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml2/blob/master/02_end_to_end_machine_learning_project.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml3/blob/main/02_end_to_end_machine_learning_project.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" </td>\n",
"</table>"
]
@ -110,7 +110,7 @@
" housing_path = Path() / \"datasets\" / \"housing\"\n",
" if not (housing_path / \"housing.csv\").is_file():\n",
" housing_path.mkdir(parents=True, exist_ok=True)\n",
" root = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"\n",
" root = \"https://raw.githubusercontent.com/ageron/handson-ml3/main/\"\n",
" url = root + \"datasets/housing/housing.tgz\"\n",
" tgz_path = housing_path / \"housing.tgz\"\n",
" urllib.request.urlretrieve(url, tgz_path)\n",
@ -592,7 +592,7 @@
"# Download the California image\n",
"filename = \"california.png\"\n",
"if not (IMAGES_PATH / filename).is_file():\n",
" root = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"\n",
" root = \"https://raw.githubusercontent.com/ageron/handson-ml3/main/\"\n",
" url = root + \"images/end_to_end_project/\" + filename\n",
" print(\"Downloading\", filename)\n",
" urllib.request.urlretrieve(url, IMAGES_PATH / filename)\n",

View File

@ -20,10 +20,10 @@
"source": [
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml2/blob/master/03_classification.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml3/blob/main/03_classification.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml2/blob/master/03_classification.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml3/blob/main/03_classification.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" </td>\n",
"</table>"
]
@ -1635,7 +1635,7 @@
" filepath = titanic_path / filename\n",
" if filepath.is_file():\n",
" continue\n",
" root = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"\n",
" root = \"https://raw.githubusercontent.com/ageron/handson-ml3/main/\"\n",
" url = root + \"/datasets/titanic/\" + filename\n",
" print(\"Downloading\", filename)\n",
" urllib.request.urlretrieve(url, filepath)\n",

View File

@ -20,10 +20,10 @@
"source": [
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml2/blob/master/04_training_linear_models.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml3/blob/main/04_training_linear_models.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml2/blob/master/04_training_linear_models.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml3/blob/main/04_training_linear_models.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" </td>\n",
"</table>"
]

View File

@ -4,14 +4,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"**Chapter 5 Decision Trees**"
"**Chapter 6 Decision Trees**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"_This notebook contains all the sample code and solutions to the exercises in chapter 5._"
"_This notebook contains all the sample code and solutions to the exercises in chapter 6._"
]
},
{
@ -20,10 +20,10 @@
"source": [
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml2/blob/master/06_decision_trees.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml3/blob/main/06_decision_trees.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml2/blob/master/06_decision_trees.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml3/blob/main/06_decision_trees.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" </td>\n",
"</table>"
]
@ -146,7 +146,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"**This code example generates Figure 51. Iris Decision Tree:**"
"**This code example generates Figure 61. Iris Decision Tree:**"
]
},
{
@ -224,7 +224,7 @@
" plt.plot(X_iris[:, 0][y_iris == idx], X_iris[:, 1][y_iris == idx],\n",
" style, label=f\"Iris {name}\")\n",
"\n",
"# not in the book this section beautifies and saves Figure 52\n",
"# not in the book this section beautifies and saves Figure 62\n",
"tree_clf_deeper = DecisionTreeClassifier(max_depth=3, random_state=42)\n",
"tree_clf_deeper.fit(X_iris, y_iris)\n",
"th0, th1, th2a, th2b = tree_clf_deeper.tree_.threshold[[0, 2, 3, 6]]\n",
@ -339,7 +339,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 53\n",
"# not in the book this cell generates and saves Figure 63\n",
"\n",
"def plot_decision_boundary(clf, X, y, axes, cmap):\n",
" x1, x2 = np.meshgrid(np.linspace(axes[0], axes[1], 100),\n",
@ -480,7 +480,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 55\n",
"# not in the book this cell generates and saves Figure 65\n",
"\n",
"def plot_regression_predictions(tree_reg, X, y, axes=[-0.5, 0.5, -0.05, 0.25]):\n",
" x1 = np.linspace(axes[0], axes[1], 500).reshape(-1, 1)\n",
@ -524,7 +524,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 56\n",
"# not in the book this cell generates and saves Figure 66\n",
"\n",
"tree_reg1 = DecisionTreeRegressor(random_state=42)\n",
"tree_reg2 = DecisionTreeRegressor(random_state=42, min_samples_leaf=10)\n",
@ -577,7 +577,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 57\n",
"# not in the book this cell generates and saves Figure 67\n",
"\n",
"np.random.seed(6)\n",
"X_square = np.random.rand(100, 2) - 0.5\n",
@ -628,7 +628,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 58\n",
"# not in the book this cell generates and saves Figure 68\n",
"\n",
"plt.figure(figsize=(8, 4))\n",
"\n",
@ -691,7 +691,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 59\n",
"# not in the book this cell generates and saves Figure 69\n",
"\n",
"plt.figure(figsize=(8, 4))\n",
"y_pred = tree_clf_tweaked.predict(X_iris_all).reshape(lengths.shape)\n",

View File

@ -4,14 +4,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"**Chapter 6 Ensemble Learning and Random Forests**"
"**Chapter 7 Ensemble Learning and Random Forests**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"_This notebook contains all the sample code and solutions to the exercises in chapter 6._"
"_This notebook contains all the sample code and solutions to the exercises in chapter 7._"
]
},
{
@ -20,10 +20,10 @@
"source": [
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml2/blob/master/07_ensemble_learning_and_random_forests.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml3/blob/main/07_ensemble_learning_and_random_forests.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml2/blob/master/07_ensemble_learning_and_random_forests.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml3/blob/main/07_ensemble_learning_and_random_forests.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" </td>\n",
"</table>"
]
@ -131,7 +131,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 63\n",
"# not in the book this cell generates and saves Figure 73\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
@ -271,7 +271,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 65\n",
"# not in the book this cell generates and saves Figure 75\n",
"\n",
"def plot_decision_boundary(clf, X, y, alpha=1.0):\n",
" axes=[-1.5, 2.4, -1, 1.5]\n",
@ -445,7 +445,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 66\n",
"# not in the book this cell generates and saves Figure 76\n",
"\n",
"from sklearn.datasets import fetch_openml\n",
"\n",
@ -478,7 +478,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 68\n",
"# not in the book this cell generates and saves Figure 78\n",
"\n",
"m = len(X_train)\n",
"\n",
@ -613,7 +613,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 69\n",
"# not in the book this cell generates and saves Figure 79\n",
"\n",
"def plot_predictions(regressors, X, y, axes, style,\n",
" label=None, data_style=\"b.\", data_label=None):\n",
@ -713,7 +713,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 610\n",
"# not in the book this cell generates and saves Figure 710\n",
"\n",
"fix, axes = plt.subplots(ncols=2, figsize=(10,4), sharey=True)\n",
"\n",
@ -753,7 +753,7 @@
" housing_path = Path() / \"datasets\" / \"housing\"\n",
" if not (housing_path / \"housing.csv\").is_file():\n",
" housing_path.mkdir(parents=True, exist_ok=True)\n",
" root = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"\n",
" root = \"https://raw.githubusercontent.com/ageron/handson-ml3/main/\"\n",
" url = root + \"datasets/housing/housing.tgz\"\n",
" tgz_path = housing_path / \"housing.tgz\"\n",
" urllib.request.urlretrieve(url, tgz_path)\n",

View File

@ -4,14 +4,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"**Chapter 7 Dimensionality Reduction**"
"**Chapter 8 Dimensionality Reduction**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"_This notebook contains all the sample code and solutions to the exercises in chapter 7._"
"_This notebook contains all the sample code and solutions to the exercises in chapter 8._"
]
},
{
@ -20,10 +20,10 @@
"source": [
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml2/blob/master/08_dimensionality_reduction.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml3/blob/main/08_dimensionality_reduction.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml2/blob/master/08_dimensionality_reduction.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml3/blob/main/08_dimensionality_reduction.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" </td>\n",
"</table>"
]
@ -175,7 +175,7 @@
},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 72\n",
"# not in the book this code generates and saves Figure 82\n",
"\n",
"import matplotlib.pyplot as plt\n",
"from mpl_toolkits.mplot3d import Axes3D\n",
@ -243,7 +243,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 73\n",
"# not in the book this code generates and saves Figure 83\n",
"\n",
"fig = plt.figure()\n",
"ax = fig.add_subplot(1, 1, 1, aspect='equal')\n",
@ -279,7 +279,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 74\n",
"# not in the book this code generates and saves Figure 84\n",
"\n",
"from matplotlib.colors import ListedColormap\n",
"\n",
@ -303,7 +303,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves plots for Figure 75\n",
"# not in the book this code generates and saves plots for Figure 85\n",
"\n",
"plt.figure(figsize=(10, 4))\n",
"\n",
@ -330,7 +330,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves plots for Figure 76\n",
"# not in the book this code generates and saves plots for Figure 86\n",
" \n",
"axes = [-11.5, 14, -2, 23, -12, 15]\n",
"x2s = np.linspace(axes[2], axes[3], 10)\n",
@ -402,7 +402,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 77\n",
"# not in the book this code generates and saves Figure 87\n",
"\n",
"angle = np.pi / 5\n",
"stretch = 5\n",
@ -795,7 +795,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 79\n",
"# not in the book this cell generates and saves Figure 89\n",
"\n",
"plt.figure(figsize=(7, 4))\n",
"for idx, X in enumerate((X_train[::2100], X_recovered[::2100])):\n",
@ -1027,7 +1027,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 710\n",
"# not in the book this cell generates and saves Figure 810\n",
"\n",
"plt.title(\"Unrolled swiss roll using LLE\")\n",
"plt.scatter(X_unrolled[:, 0], X_unrolled[:, 1],\n",
@ -1099,7 +1099,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 711\n",
"# not in the book this cell generates and saves Figure 811\n",
"\n",
"titles = [\"MDS\", \"Isomap\", \"t-SNE\"]\n",
"\n",

View File

@ -4,14 +4,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"**Chapter 8 Unsupervised Learning**"
"**Chapter 9 Unsupervised Learning**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"_This notebook contains all the sample code and solutions to the exercises in chapter 8._"
"_This notebook contains all the sample code and solutions to the exercises in chapter 9._"
]
},
{
@ -20,10 +20,10 @@
"source": [
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml2/blob/master/09_unsupervised_learning.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml3/blob/main/09_unsupervised_learning.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml2/blob/master/09_unsupervised_learning.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml3/blob/main/09_unsupervised_learning.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" </td>\n",
"</table>"
]
@ -145,7 +145,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 81\n",
"# not in the book this code generates and saves Figure 91\n",
"\n",
"import matplotlib.pyplot as plt\n",
"from sklearn.datasets import load_iris\n",
@ -286,7 +286,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 82\n",
"# not in the book this code generates and saves Figure 92\n",
"\n",
"def plot_clusters(X, y=None):\n",
" plt.scatter(X[:, 0], X[:, 1], c=y, s=1)\n",
@ -397,7 +397,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 83\n",
"# not in the book this code generates and saves Figure 93\n",
"\n",
"def plot_data(X):\n",
" plt.plot(X[:, 0], X[:, 1], 'k.', markersize=2)\n",
@ -530,7 +530,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 84\n",
"# not in the book this code generates and saves Figure 94\n",
"\n",
"kmeans_iter1 = KMeans(n_clusters=5, init=\"random\", n_init=1, max_iter=1,\n",
" random_state=5)\n",
@ -598,7 +598,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 85\n",
"# not in the book this code generates and saves Figure 95\n",
"\n",
"def plot_clusterer_comparison(clusterer1, clusterer2, X, title1=None,\n",
" title2=None):\n",
@ -962,7 +962,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 86\n",
"# not in the book this code generates and saves Figure 96\n",
"\n",
"from timeit import timeit\n",
"\n",
@ -1022,7 +1022,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 87\n",
"# not in the book this code generates and saves Figure 97\n",
"\n",
"kmeans_k3 = KMeans(n_clusters=3, random_state=42)\n",
"kmeans_k8 = KMeans(n_clusters=8, random_state=42)\n",
@ -1070,7 +1070,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 88\n",
"# not in the book this code generates and saves Figure 98\n",
"\n",
"kmeans_per_k = [KMeans(n_clusters=k, random_state=42).fit(X)\n",
" for k in range(1, 10)]\n",
@ -1145,7 +1145,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 89\n",
"# not in the book this code generates and saves Figure 99\n",
"\n",
"silhouette_scores = [silhouette_score(X, model.labels_)\n",
" for model in kmeans_per_k[1:]]\n",
@ -1180,7 +1180,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 810\n",
"# not in the book this code generates and saves Figure 910\n",
"\n",
"from sklearn.metrics import silhouette_samples\n",
"from matplotlib.ticker import FixedLocator, FixedFormatter\n",
@ -1251,7 +1251,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 811\n",
"# not in the book this code generates and saves Figure 911\n",
"\n",
"X1, y1 = make_blobs(n_samples=1000, centers=((4, -4), (0, 0)), random_state=42)\n",
"X1 = X1.dot(np.array([[0.374, 0.95], [0.732, 0.598]]))\n",
@ -1303,7 +1303,7 @@
"source": [
"# not in the book\n",
"\n",
"root = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"\n",
"root = \"https://raw.githubusercontent.com/ageron/handson-ml3/main/\"\n",
"filename = \"ladybug.png\"\n",
"filepath = IMAGES_PATH / filename\n",
"if not filepath.is_file():\n",
@ -1342,7 +1342,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 812\n",
"# not in the book this code generates and saves Figure 912\n",
"\n",
"segmented_imgs = []\n",
"n_colors = (10, 8, 6, 4, 2)\n",
@ -1477,7 +1477,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 813\n",
"# not in the book this cell generates and saves Figure 913\n",
"\n",
"plt.figure(figsize=(8, 2))\n",
"for index, X_representative_digit in enumerate(X_representative_digits):\n",
@ -1692,7 +1692,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 814\n",
"# not in the book this cell generates and saves Figure 914\n",
"\n",
"def plot_dbscan(dbscan, X, size, show_xlabels=True, show_ylabels=True):\n",
" core_mask = np.zeros_like(dbscan.labels_, dtype=bool)\n",
@ -1785,7 +1785,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 815\n",
"# not in the book this cell generates and saves Figure 915\n",
"\n",
"plt.figure(figsize=(6, 3))\n",
"plot_decision_boundaries(knn, X, show_centroids=False)\n",
@ -2195,7 +2195,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cells generates and saves Figure 816\n",
"# not in the book this cells generates and saves Figure 916\n",
"\n",
"from matplotlib.colors import LogNorm\n",
"\n",
@ -2254,7 +2254,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 817\n",
"# not in the book this code generates and saves Figure 917\n",
"\n",
"gm_full = GaussianMixture(n_components=3, n_init=10,\n",
" covariance_type=\"full\", random_state=42)\n",
@ -2329,7 +2329,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this code generates and saves Figure 818\n",
"# not in the book this code generates and saves Figure 918\n",
"\n",
"plt.figure(figsize=(8, 4))\n",
"\n",
@ -2371,7 +2371,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 819\n",
"# not in the book this cell generates and saves Figure 919\n",
"\n",
"from scipy.stats import norm\n",
"\n",
@ -2512,7 +2512,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 820\n",
"# not in the book this cell generates and saves Figure 920\n",
"\n",
"gms_per_k = [GaussianMixture(n_components=k, n_init=10, random_state=42).fit(X)\n",
" for k in range(1, 11)]\n",
@ -2574,7 +2574,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this figure is almost identical to Figure 816\n",
"# not in the book this figure is almost identical to Figure 916\n",
"plt.figure(figsize=(8, 5))\n",
"plot_gaussian_mixture(bgm, X)\n",
"plt.show()"
@ -2586,7 +2586,7 @@
"metadata": {},
"outputs": [],
"source": [
"# not in the book this cell generates and saves Figure 821\n",
"# not in the book this cell generates and saves Figure 921\n",
"\n",
"X_moons, y_moons = make_moons(n_samples=1000, noise=0.05, random_state=42)\n",
"\n",

View File

@ -6,10 +6,10 @@ To install this repository and run the Jupyter notebooks on your machine, you wi
Next, clone this repository by opening a terminal and typing the following commands (do not type the first `$` on each line, it's just a convention to show that this is a terminal prompt, not something else like Python code):
$ cd $HOME # or any other development directory you prefer
$ git clone https://github.com/ageron/handson-ml2.git
$ cd handson-ml2
$ git clone https://github.com/ageron/handson-ml3.git
$ cd handson-ml3
If you do not want to install git, you can instead download [master.zip](https://github.com/ageron/handson-ml2/archive/master.zip), unzip it, rename the resulting directory to `handson-ml2` and move it to your development directory.
If you do not want to install git, you can instead download [main.zip](https://github.com/ageron/handson-ml3/archive/main.zip), unzip it, rename the resulting directory to `handson-ml3` and move it to your development directory.
## Install Anaconda
Next, you will need Python 3 and a bunch of Python libraries. The simplest way to install these is to [download and install Anaconda](https://www.anaconda.com/distribution/), which is a great cross-platform Python distribution for scientific computing. It comes bundled with many scientific libraries, including NumPy, Pandas, Matplotlib, Scikit-Learn and much more, so it's quite a large installation. If you prefer a lighter weight Anaconda distribution, you can [install Miniconda](https://docs.conda.io/en/latest/miniconda.html), which contains the bare minimum to run the `conda` packaging tool. You should install the latest version of Anaconda (or Miniconda) available.
@ -29,7 +29,7 @@ Once Anaconda (or Miniconda) is installed, run the following command to update t
If you have a TensorFlow-compatible GPU card (NVidia card with Compute Capability ≥ 3.5), and you want TensorFlow to use it, then you should download the latest driver for your card from [nvidia.com](https://www.nvidia.com/Download/index.aspx?lang=en-us) and install it. You will also need NVidia's CUDA and cuDNN libraries, but the good news is that they will be installed automatically when you install the tensorflow-gpu package from Anaconda. However, if you don't use Anaconda, you will have to install them manually. If you hit any roadblock, see TensorFlow's [GPU installation instructions](https://tensorflow.org/install/gpu) for more details.
## Create the `tf2` Environment
Next, make sure you're in the `handson-ml2` directory and run the following command. It will create a new `conda` environment containing every library you will need to run all the notebooks (by default, the environment will be named `tf2`, but you can choose another name using the `-n` option):
Next, make sure you're in the `handson-ml3` directory and run the following command. It will create a new `conda` environment containing every library you will need to run all the notebooks (by default, the environment will be named `tf2`, but you can choose another name using the `-n` option):
$ conda env create -f environment.yml
@ -54,7 +54,7 @@ Congrats! You are ready to learn Machine Learning, hands on!
When you're done with Jupyter, you can close it by typing Ctrl-C in the Terminal window where you started it. Every time you want to work on this project, you will need to open a Terminal, and run:
$ cd $HOME # or whatever development directory you chose earlier
$ cd handson-ml2
$ cd handson-ml3
$ conda activate tf2
$ jupyter notebook
@ -64,7 +64,7 @@ I regularly update the notebooks to fix issues and add support for new libraries
For this, open a terminal, and run:
$ cd $HOME # or whatever development directory you chose earlier
$ cd handson-ml2 # go to this project's directory
$ cd handson-ml3 # go to this project's directory
$ git pull
If you get an error, it's probably because you modified a notebook. In this case, before running `git pull` you will first need to commit your changes. I recommend doing this in your own branch, or else you may get conflicts:
@ -72,7 +72,7 @@ If you get an error, it's probably because you modified a notebook. In this case
$ git checkout -b my_branch # you can use another branch name if you want
$ git add -u
$ git commit -m "describe your changes here"
$ git checkout master
$ git checkout main
$ git pull
Next, let's update the libraries. First, let's update `conda` itself:

View File

@ -15,22 +15,22 @@ Use any of the following services (I recommended Colab or Kaggle, since they off
**WARNING**: _Please be aware that these services provide temporary environments: anything you do will be deleted after a while, so make sure you download any data you care about._
* <a href="https://colab.research.google.com/github/ageron/handson-ml2/blob/master/" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
* <a href="https://colab.research.google.com/github/ageron/handson-ml3/blob/main/" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
* <a href="https://homl.info/kaggle/"><img src="https://kaggle.com/static/images/open-in-kaggle.svg" alt="Open in Kaggle" /></a>
* <a href="https://mybinder.org/v2/gh/ageron/handson-ml2/HEAD?filepath=%2Findex.ipynb"><img src="https://mybinder.org/badge_logo.svg" alt="Launch binder" /></a>
* <a href="https://mybinder.org/v2/gh/ageron/handson-ml3/HEAD?filepath=%2Findex.ipynb"><img src="https://mybinder.org/badge_logo.svg" alt="Launch binder" /></a>
* <a href="https://homl.info/deepnote/"><img src="https://deepnote.com/buttons/launch-in-deepnote-small.svg" alt="Launch in Deepnote" /></a>
### Just want to quickly look at some notebooks, without executing any code?
* <a href="https://nbviewer.jupyter.org/github/ageron/handson-ml2/blob/master/index.ipynb"><img src="https://raw.githubusercontent.com/jupyter/design/master/logos/Badges/nbviewer_badge.svg" alt="Render nbviewer" /></a>
* <a href="https://nbviewer.jupyter.org/github/ageron/handson-ml3/blob/main/index.ipynb"><img src="https://raw.githubusercontent.com/jupyter/design/master/logos/Badges/nbviewer_badge.svg" alt="Render nbviewer" /></a>
* [github.com's notebook viewer](https://github.com/ageron/handson-ml2/blob/master/index.ipynb) also works but it's not ideal: it's slower, the math equations are not always displayed correctly, and large notebooks often fail to open.
* [github.com's notebook viewer](https://github.com/ageron/handson-ml3/blob/main/index.ipynb) also works but it's not ideal: it's slower, the math equations are not always displayed correctly, and large notebooks often fail to open.
### Want to run this project using a Docker image?
Read the [Docker instructions](https://github.com/ageron/handson-ml2/tree/master/docker).
Read the [Docker instructions](https://github.com/ageron/handson-ml3/tree/main/docker).
### Want to install this project on your own machine?
@ -38,8 +38,8 @@ Start by installing [Anaconda](https://www.anaconda.com/distribution/) (or [Mini
Next, clone this project by opening a terminal and typing the following commands (do not type the first `$` signs on each line, they just indicate that these are terminal commands):
$ git clone https://github.com/ageron/handson-ml2.git
$ cd handson-ml2
$ git clone https://github.com/ageron/handson-ml3.git
$ cd handson-ml3
Next, run the following commands:
@ -76,4 +76,4 @@ See [INSTALL.md](INSTALL.md)
See [INSTALL.md](INSTALL.md)
## Contributors
I would like to thank everyone [who contributed to this project](https://github.com/ageron/handson-ml2/graphs/contributors), either by providing useful feedback, filing issues or submitting Pull Requests. Special thanks go to Haesun Park and Ian Beauregard who reviewed every notebook and submitted many PRs, including help on some of the exercise solutions. Thanks as well to Steven Bunkley and Ziembla who created the `docker` directory, and to github user SuperYorio who helped on some exercise solutions.
I would like to thank everyone [who contributed to this project](https://github.com/ageron/handson-ml3/graphs/contributors), either by providing useful feedback, filing issues or submitting Pull Requests. Special thanks go to Haesun Park and Ian Beauregard who reviewed every notebook and submitted many PRs, including help on some of the exercise solutions. Thanks as well to Steven Bunkley and Ziembla who created the `docker` directory, and to github user SuperYorio who helped on some exercise solutions.

View File

@ -1 +1 @@
COMPOSE_PROJECT_NAME=handson-ml2
COMPOSE_PROJECT_NAME=handson-ml3

View File

@ -31,7 +31,7 @@ ARG username
ARG userid
ARG home=/home/${username}
ARG workdir=${home}/handson-ml2
ARG workdir=${home}/handson-ml3
RUN adduser ${username} --uid ${userid} --gecos '' --disabled-password \
&& echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} \
@ -47,7 +47,7 @@ ENV PATH /opt/conda/envs/tf2/bin:$PATH
# The config below enables diffing notebooks with nbdiff (and nbdiff support
# in git diff command) after connecting to the container by "make exec" (or
# "docker-compose exec handson-ml2 bash")
# "docker-compose exec handson-ml3 bash")
# You may also try running:
# nbdiff NOTEBOOK_NAME.ipynb
# to get nbdiff between checkpointed version and current version of the

View File

@ -27,7 +27,7 @@ ARG LIBNVINFER_MAJOR_VERSION=7
# Needed for string substitution
SHELL ["/bin/bash", "-c"]
# Pick up some TF dependencies
# [HOML2] Tweaked for handson-ml2: added all the libs before build-essentials
# [HOML2] Tweaked for handson-ml3: added all the libs before build-essentials
# and call apt clean + remove apt cache.
RUN apt-get update -q && apt-get install -q -y --no-install-recommends \
bzip2 \
@ -87,7 +87,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib
&& echo "/usr/local/cuda/lib64/stubs" > /etc/ld.so.conf.d/z-cuda-stubs.conf \
&& ldconfig
# [HOML2] Tweaked for handson-ml2: removed Python3 & TensorFlow installation using pip
# [HOML2] Tweaked for handson-ml3: removed Python3 & TensorFlow installation using pip
#################################################
#### End of tensorflow/tensorflow:latest-gpu ####
@ -102,7 +102,7 @@ ENV PATH /opt/conda/bin:/opt/conda/envs/tf2/bin:$PATH
#### FROM continuumio/miniconda3:latest ####
############################################
# [HOML2] Tweaked for handson-ml2: removed the beginning of the Dockerfile
# [HOML2] Tweaked for handson-ml3: removed the beginning of the Dockerfile
CMD [ "/bin/bash" ]
# Leave these args here to better use the Docker build cache
@ -141,7 +141,7 @@ ARG username
ARG userid
ARG home=/home/${username}
ARG workdir=${home}/handson-ml2
ARG workdir=${home}/handson-ml3
RUN adduser ${username} --uid ${userid} --gecos '' --disabled-password \
&& echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} \
@ -156,7 +156,7 @@ WORKDIR ${workdir}
# The config below enables diffing notebooks with nbdiff (and nbdiff support
# in git diff command) after connecting to the container by "make exec" (or
# "docker-compose exec handson-ml2 bash")
# "docker-compose exec handson-ml3 bash")
# You may also try running:
# nbdiff NOTEBOOK_NAME.ipynb
# to get nbdiff between checkpointed version and current version of the

View File

@ -4,11 +4,11 @@ help:
run:
docker-compose up
exec:
docker-compose exec handson-ml2 bash
docker-compose exec handson-ml3 bash
build: stop .FORCE
docker-compose build
rebuild: stop .FORCE
docker-compose build --no-cache
stop:
docker stop handson-ml2 || true; docker rm handson-ml2 || true;
docker stop handson-ml3 || true; docker rm handson-ml3 || true;
.FORCE:

View File

@ -16,34 +16,34 @@ Some general knowledge about `docker` infrastructure might be useful (that's an
The first option is to pull the image from Docker Hub (this will download about 1.9 GB of compressed data):
```bash
$ docker pull ageron/handson-ml2
$ docker pull ageron/handson-ml3
```
**Note**: this is the CPU-only image. For GPU support, read the GPU section below.
Alternatively, you can build the image yourself. This will be slower, but it will ensure the image is up to date, with the latest libraries. For this, assuming you already downloaded this project into the directory `/path/to/project/handson-ml2`:
Alternatively, you can build the image yourself. This will be slower, but it will ensure the image is up to date, with the latest libraries. For this, assuming you already downloaded this project into the directory `/path/to/project/handson-ml3`:
```bash
$ cd /path/to/project/handson-ml2/docker
$ cd /path/to/project/handson-ml3/docker
$ docker-compose build
```
This will take quite a while, but is only required once.
After the process is finished you have an `ageron/handson-ml2:latest` image, that will be the base for your experiments. You can confirm that by running the following command:
After the process is finished you have an `ageron/handson-ml3:latest` image, that will be the base for your experiments. You can confirm that by running the following command:
```bash
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ageron/handson-ml2 latest 3ebafebc604a 2 minutes ago 4.87GB
ageron/handson-ml3 latest 3ebafebc604a 2 minutes ago 4.87GB
```
### Run the notebooks
Still assuming you already downloaded this project into the directory `/path/to/project/handson-ml2`, run the following commands to start the Jupyter server inside the container, which is named `handson-ml2`:
Still assuming you already downloaded this project into the directory `/path/to/project/handson-ml3`, run the following commands to start the Jupyter server inside the container, which is named `handson-ml3`:
```bash
$ cd /path/to/project/handson-ml2/docker
$ cd /path/to/project/handson-ml3/docker
$ docker-compose up
```
@ -55,13 +55,13 @@ You can close the server just by pressing `Ctrl-C` in the terminal window.
### Using `make` (optional)
If you have `make` installed on your computer, you can use it as a thin layer to run `docker-compose` commands. For example, executing `make rebuild` will actually run `docker-compose build --no-cache`, which will rebuild the image without using the cache. This ensures that your image is based on the latest version of the `continuumio/miniconda3` image which the `ageron/handson-ml2` image is based on.
If you have `make` installed on your computer, you can use it as a thin layer to run `docker-compose` commands. For example, executing `make rebuild` will actually run `docker-compose build --no-cache`, which will rebuild the image without using the cache. This ensures that your image is based on the latest version of the `continuumio/miniconda3` image which the `ageron/handson-ml3` image is based on.
If you don't have `make` (and you don't want to install it), just examine the contents of `Makefile` to see which `docker-compose` commands you can run instead.
### Run additional commands in the container
Run `make exec` (or `docker-compose exec handson-ml2 bash`) while the server is running to run an additional `bash` shell inside the `handson-ml2` container. Now you're inside the environment prepared within the image.
Run `make exec` (or `docker-compose exec handson-ml3 bash`) while the server is running to run an additional `bash` shell inside the `handson-ml3` container. Now you're inside the environment prepared within the image.
One of the useful things that can be done there would be starting TensorBoard (for example with simple `tb` command, see bashrc file).
@ -81,12 +81,12 @@ If you're running on Linux, and you have a TensorFlow-compatible GPU card (NVidi
Next, edit the `docker-compose.yml` file:
```bash
$ cd /path/to/project/handson-ml2/docker
$ cd /path/to/project/handson-ml3/docker
$ edit docker-compose.yml # use your favorite editor
```
* Replace `dockerfile: ./docker/Dockerfile` with `dockerfile: ./docker/Dockerfile.gpu`
* Replace `image: ageron/handson-ml2:latest` with `image: ageron/handson-ml2:latest-gpu`
* Replace `image: ageron/handson-ml3:latest` with `image: ageron/handson-ml3:latest-gpu`
* If you want to use `docker-compose`, you will need version 1.28 or above for GPU support, and you must uncomment the whole `deploy` section in `docker-compose.yml`.
### Prepare the image (once)
@ -94,13 +94,13 @@ $ edit docker-compose.yml # use your favorite editor
If you want to pull the prebuilt image from Docker Hub (this will download over 3.5 GB of compressed data):
```bash
$ docker pull ageron/handson-ml2:latest-gpu
$ docker pull ageron/handson-ml3:latest-gpu
```
If you prefer to build the image yourself:
```bash
$ cd /path/to/project/handson-ml2/docker
$ cd /path/to/project/handson-ml3/docker
$ docker-compose build
```
@ -109,7 +109,7 @@ $ docker-compose build
If you have `docker-compose` version 1.28 or above, that's great! You can simply run:
```bash
$ cd /path/to/project/handson-ml2/docker
$ cd /path/to/project/handson-ml3/docker
$ docker-compose up
[...]
or http://127.0.0.1:8888/?token=[...]
@ -132,8 +132,8 @@ If you have a version of `docker-compose` earlier than 1.28, you will have to us
If you are using Docker 19.03 or above, you can run:
```bash
$ cd /path/to/project/handson-ml2
$ docker run --name handson-ml2 --gpus all -p 8888:8888 -p 6006:6006 --log-opt mode=non-blocking --log-opt max-buffer-size=50m -v `pwd`:/home/devel/handson-ml2 ageron/handson-ml2:latest-gpu /opt/conda/envs/tf2/bin/jupyter notebook --ip='0.0.0.0' --port=8888 --no-browser
$ cd /path/to/project/handson-ml3
$ docker run --name handson-ml3 --gpus all -p 8888:8888 -p 6006:6006 --log-opt mode=non-blocking --log-opt max-buffer-size=50m -v `pwd`:/home/devel/handson-ml3 ageron/handson-ml3:latest-gpu /opt/conda/envs/tf2/bin/jupyter notebook --ip='0.0.0.0' --port=8888 --no-browser
```
If you are using an older version of Docker, then replace `--gpus all` with `--runtime=nvidia`.
@ -143,7 +143,7 @@ Now point your browser to the displayed URL: Jupyter should appear, and you can
Lastly, to interrupt the server, press Ctrl-C, then run:
```bash
$ docker rm handson-ml2
$ docker rm handson-ml3
```
This will remove the container so you can start a new one later (but it will not remove the image or the notebooks, don't worry!).

View File

@ -1,14 +1,14 @@
version: "3"
services:
handson-ml2:
handson-ml3:
build:
context: ../
dockerfile: ./docker/Dockerfile #Dockerfile.gpu
args:
- username=devel
- userid=1000
container_name: handson-ml2
image: ageron/handson-ml2:latest #latest-gpu
container_name: handson-ml3
image: ageron/handson-ml3:latest #latest-gpu
restart: unless-stopped
logging:
driver: json-file
@ -18,7 +18,7 @@ services:
- "8888:8888"
- "6006:6006"
volumes:
- ../:/home/devel/handson-ml2
- ../:/home/devel/handson-ml3
command: /opt/conda/envs/tf2/bin/jupyter notebook --ip='0.0.0.0' --port=8888 --no-browser
#deploy:
# resources:

View File

@ -20,10 +20,10 @@
"source": [
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml2/blob/master/extra_autodiff.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml3/blob/main/extra_autodiff.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml2/blob/master/extra_autodiff.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml3/blob/main/extra_autodiff.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" </td>\n",
"</table>"
]

View File

@ -12,7 +12,7 @@
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml2/blob/master/index.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml3/blob/main/index.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://homl.info/kaggle/\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
@ -103,7 +103,7 @@
"metadata": {},
"source": [
"### To run the examples\n",
"* **Jupyter** These notebooks are based on Jupyter. You can run these notebooks in just one click using a hosted platform such as Binder, Deepnote or Colaboratory (no installation required), or you can just view them using Jupyter.org's viewer, or you can install everything on your machine, as you prefer. Check out the [home page](https://github.com/ageron/handson-ml2/) for more details."
"* **Jupyter** These notebooks are based on Jupyter. You can run these notebooks in just one click using a hosted platform such as Binder, Deepnote or Colaboratory (no installation required), or you can just view them using Jupyter.org's viewer, or you can install everything on your machine, as you prefer. Check out the [home page](https://github.com/ageron/handson-ml3/) for more details."
]
},
{

View File

@ -19,10 +19,10 @@
"source": [
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml2/blob/master/math_differential_calculus.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml3/blob/main/math_differential_calculus.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml2/blob/master/math_differential_calculus.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml3/blob/main/math_differential_calculus.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" </td>\n",
"</table>"
]
@ -476,7 +476,7 @@
"id": "ebb31wJp72Zn"
},
"source": [
"**Important note:** in Deep Learning, differentiation is almost always performed automatically by the framework you are using (such as TensorFlow or PyTorch). This is called auto-diff, and I did [another notebook](https://github.com/ageron/handson-ml2/blob/master/extra_autodiff.ipynb) on that topic. However, you should still make sure you have a good understanding of derivatives, or else they will come and bite you one day, for example when you use a square root in your cost function without realizing that its derivative approaches infinity when $x$ approaches 0 (tip: you should use $\\sqrt{x+\\epsilon}$ instead, where $\\epsilon$ is some small constant, such as $10^{-4}$)."
"**Important note:** in Deep Learning, differentiation is almost always performed automatically by the framework you are using (such as TensorFlow or PyTorch). This is called auto-diff, and I did [another notebook](https://github.com/ageron/handson-ml3/blob/main/extra_autodiff.ipynb) on that topic. However, you should still make sure you have a good understanding of derivatives, or else they will come and bite you one day, for example when you use a square root in your cost function without realizing that its derivative approaches infinity when $x$ approaches 0 (tip: you should use $\\sqrt{x+\\epsilon}$ instead, where $\\epsilon$ is some small constant, such as $10^{-4}$)."
]
},
{
@ -1064,7 +1064,7 @@
" zs = f(xs, ys)\n",
"\n",
" surface = ax.plot_surface(xs, ys, zs,\n",
" cmap=mpl.cm.coolwarm,\n",
" cmap=\"coolwarm\",\n",
" linewidth=0.3, edgecolor='k')\n",
"\n",
" ax.set_xlabel(\"$x$\", fontsize=14)\n",

View File

@ -18,10 +18,10 @@
"source": [
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml2/blob/master/tools_pandas.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml3/blob/main/tools_pandas.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml2/blob/master/tools_pandas.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml3/blob/main/tools_pandas.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
" </td>\n",
"</table>"
]