Skip to content

Commit

Permalink
Merge pull request #107 from gtbook/frank_feb10
Browse files Browse the repository at this point in the history
Chapter 6
  • Loading branch information
dellaert authored Feb 13, 2025
2 parents 6dbaa09 + 24412ca commit c274e37
Show file tree
Hide file tree
Showing 16 changed files with 950 additions and 1,023 deletions.
2 changes: 1 addition & 1 deletion S23_sorter_sensing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"id": "1SqwIzxjWfu6",
"metadata": {},
"source": [
"As an example, in Figure [1](fig:category_prior) we define a CPT for our binary sensor example and pretty-print it. Note the rows add up to 1.0, as each row is a valid probability mass function (PMF)."
"As an example, in Figure [1](#fig:category_prior) we define a CPT for our binary sensor example and pretty-print it. Note the rows add up to 1.0, as each row is a valid probability mass function (PMF)."
]
},
{
Expand Down
24 changes: 10 additions & 14 deletions S34_vacuum_perception.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "E5rsQom9hatQ",
"metadata": {
"tags": [
Expand All @@ -40,12 +40,12 @@
}
],
"source": [
"%pip install -U -q gtbook\n"
"%pip install -U -q gtbook"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "OFkNEfdX_CLe",
"metadata": {
"tags": [
Expand Down Expand Up @@ -74,12 +74,12 @@
" import google.colab\n",
"except:\n",
" import plotly.io as pio\n",
" pio.renderers.default = \"png\"\n"
" pio.renderers.default = \"png\""
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "gIariOyXd8PE",
"metadata": {
"tags": [
Expand All @@ -104,7 +104,7 @@
"N = 3\n",
"X = VARIABLES.discrete_series(\"X\", range(1, N+1), vacuum.rooms)\n",
"A = VARIABLES.discrete_series(\"A\", range(1, N), vacuum.action_space)\n",
"Z = VARIABLES.discrete_series(\"Z\", range(1, N+1), vacuum.light_levels)\n"
"Z = VARIABLES.discrete_series(\"Z\", range(1, N+1), vacuum.light_levels)"
]
},
{
Expand Down Expand Up @@ -458,7 +458,7 @@
"<figcaption>An HMM for three time steps, represented as a Bayes net.</figcaption>\n",
"</figure>\n",
"\n",
"Figure [3.9](#fig:unrolledHMM) shows an example of an HMM for three time steps, i.e., \n",
"Figure [2](#fig:unrolledHMM) shows an example of an HMM for three time steps, i.e., \n",
"$\\mathcal{X}=\\{X_1, X_2, X_3\\}$ and\n",
"$\\mathcal{Z}=\\{Z_1, Z_2, Z_3\\}$. As discussed above, in a Bayes net\n",
"each node is associated with a conditional distribution: the Markov\n",
Expand Down Expand Up @@ -750,7 +750,7 @@
"we only represent the *hidden* variables $X_1$, $X_2$, and $X_3$, \n",
"connected to factors that encode probabilistic information. For\n",
"our example with three hidden states, the corresponding factor graph is\n",
"shown in Figure [3.25](#fig:HMM-FG).\n",
"shown in Figure [4](#fig:HMM-FG).\n",
"It should be clear from the figure that the connectivity of a factor\n",
"graph encodes, for each factor $\\phi_{i}$, which subset of variables\n",
"$\\mathcal{X}_{i}$ it depends on. We write:\n",
Expand Down Expand Up @@ -793,9 +793,7 @@
"In other words, the independence relationships are encoded by the edges\n",
"$e_{ij}$ of the factor graph, with each factor $\\phi_{i}$ a function of\n",
"*only* the variables $\\mathcal{X}_{i}$ in its adjacency set. As example, \n",
"for the factor graph in Figure\n",
"<a href=\"#fig:HMM-FG\" data-reference-type=\"ref\" data-reference=\"fig:HMM-FG\">2</a>\n",
"we have: \n",
"for the factor graph in Figure [4](#fig:HMM-FG) we have: \n",
"\\begin{equation}\n",
"\\begin{aligned}\n",
"\\mathcal{X}_1 & =\\{X_1\\}\\\\\n",
Expand Down Expand Up @@ -1161,9 +1159,7 @@
"Given an HMM factor graph of size $n$, the **max-product algorithm** is an $O(n)$ algorithm\n",
"to find the MAP estimate, which is used by GTSAM under the hood.\n",
"\n",
"Let us use the example from Figure\n",
"<a href=\"#fig:HMM-FG\" data-reference-type=\"ref\" data-reference=\"fig:HMM-FG\">2</a>\n",
"to understand the main idea behind it. To find the MAP estimate for $\\mathcal{X}$ we need to\n",
"Let us use the example from Figure [4](#fig:HMM-FG) to understand the main idea behind it. To find the MAP estimate for $\\mathcal{X}$ we need to\n",
"*maximize* the product\n",
"\\begin{equation}\n",
"\\phi(X_1, X_2, X_3)=\\prod\\phi_{i}(\\mathcal{X}_{i})\n",
Expand Down
4 changes: 2 additions & 2 deletions S44_logistics_perception.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@
"\\begin{equation}\n",
"\\Phi(X)=\\sum_i \\phi(X_i) = \\frac{1}{2} \\sum_i \\|A_i X_i-b_i\\|^2.\n",
"\\end{equation}\n",
"In the continuous case we use *minimization* of the log-likelihood rather than maximization over the probabilities. The main reason is because then inference becomes a linear least squares problem."
"In the continuous case we use *minimization* of the log-likelihood rather than maximization over the probabilities. The main reason is because then inference becomes a linear least-squares problem."
]
},
{
Expand Down Expand Up @@ -1320,7 +1320,7 @@
"id": "pDcm35cDLftk",
"metadata": {},
"source": [
"### Sparse Least-Squares\n",
"### Sparse Least Squares\n",
"\n",
"In practice we use *sparse factorization methods* to solve for $X^*$. In particular, *sparse Cholesky* factorization can efficiently decompose the sparse Hessian $Q$ into its matrix square root $R$\n",
"\\begin{equation}\n",
Expand Down
8 changes: 0 additions & 8 deletions S54_diffdrive_perception.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,10 @@
"For example, the first pixel in the edge image has the value 2, which is calculated from the values \n",
"$\\begin{bmatrix}3 & 3 & 5\\end{bmatrix}$, as highlighted below:\n",
"\\begin{equation}\n",
"\\begin{align}\n",
"\\begin{bmatrix}\n",
"3 & \\textbf{3} & \\textbf{3} & \\textbf{5} & 5 & 5 & 5 & 2 & 2 & 2 \\\\\n",
"3 & 0 & \\textbf{2} & 2 & 0 & 0 & -3 & -3 & 0 & -2\n",
"\\end{bmatrix}\n",
"\\end{align}\n",
"\\end{equation}\n",
"The \"recipe\" to calculate the edge value is just taking a weighted sum,\n",
"where the weights are defined by our filter:\n",
Expand Down Expand Up @@ -343,12 +341,10 @@
"```\n",
"Let us examine the input and output again:\n",
"\\begin{equation}\n",
"\\begin{align}\n",
"\\begin{bmatrix}\n",
"3 & 3 & 3 & 5 & 5 & 5 & 5 & 2 & 2 & 2 \\\\\n",
"3 & 0 & 2 & 2 & 0 & 0 & -3 & -3 & 0 & -2\n",
"\\end{bmatrix}\n",
"\\end{align}\n",
"\\end{equation}\n",
"We already understand the first $2$. The output pixel next to it *also* has the value $2$, as you can verify using the formula. You might object to the fact that the edge seems to be \"doubly wide\", and that we could do better with the simpler filter $\\begin{bmatrix}-1 & 1\\end{bmatrix}$, which people also use. However, making a $1\\times 3$ filter with a zero in the middle ensures that the edges do not \"shift\". The resulting simple filter is widely used and known a **Sobel filter**.\n",
"\n",
Expand Down Expand Up @@ -394,15 +390,11 @@
"\n",
"Armed with this formula, we can now understand the edge detection above. For each output pixel $h[i,j]$, we do a pointwise multiplication of the $1 \\times 3$ filter \n",
"\\begin{equation}\n",
"\\begin{align}\n",
"\\begin{pmatrix}g[0,-1] & g[0,0] & g[0,1]\\end{pmatrix} = \\begin{pmatrix}-1 & 0 & 1\\end{pmatrix}\n",
"\\end{align}\n",
"\\end{equation}\n",
"with the $1 \\times 3$ window \n",
"\\begin{equation}\n",
"\\begin{align}\n",
"\\begin{pmatrix}f[i,j-1] & f[i,j+0] & f[i,j+1]\\end{pmatrix}\n",
"\\end{align}\n",
"\\end{equation}\n",
"in the input image $f$.\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion S56_diffdrive_learning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@
"source": [
"We can then use the PyTorch training code below, which is a standard way of training any differentiable function, including our `LineGrid` class. That is because all the operations inside the `LineGrid` class are differentiable, so gradient descent will just work.\n",
"\n",
"Inside the training loop below, you'll find the typical sequence of operations: zeroing gradients, performing a forward pass to get predictions, computing the loss, and doing a backward pass to update the model's parameters. Try to understand the code, as this same training loop is at the core of most deep learning architectures. Now, let's take a closer look at the code itself, which is extensively documented for clarity, and listed in Figure [2](#train_gd)."
"Inside the training loop below, you'll find the typical sequence of operations: zeroing gradients, performing a forward pass to get predictions, computing the loss, and doing a backward pass to update the model's parameters. Try to understand the code, as this same training loop is at the core of most deep learning architectures. Now, let's take a closer look at the code itself, which is extensively documented for clarity, and listed in Figure [2](#code:train_gd)."
]
},
{
Expand Down
18 changes: 17 additions & 1 deletion S60_driving_intro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"source": [
"# Autonomous Vehicles\n",
"\n",
"```{index} self-driving cars\n",
"```\n",
"> Self-driving cars can be thought of as large-scale wheeled mobile robots that navigate in the real world based on sensor data.\n",
"\n",
"<img src=\"Figures6/S60-Autonomous_Vehicle_with_LIDAR_and_cameras-09.jpg\" alt=\"Splash image with steampunk autonomous car\" width=\"60%\" align=center style=\"vertical-align:middle;margin:10px 0px\">\n"
Expand All @@ -18,13 +20,27 @@
"id": "YhpQ6vC4mBFg",
"metadata": {},
"source": [
"```{index} autonomous driving\n",
"```\n",
"In this chapter we look at some of the basic concepts involved in autonomous driving. Needless to say, the topic of autonomous vehicles is rather large, and we only cover a small selection in this chapter. \n",
"\n",
"```{index} SO(2), SE(2), Ackermann steering\n",
"```\n",
"We begin by becoming a bit more serious about movement in the plane, first introducing the matrix group SO(2) to represent rotation in the plane, and then extending this to the matrix group SE(2), which can be used to represent both rotation and translation in the plane. We then introduce kinematics in the form of Ackermann steering, which is common in automobiles. \n",
"\n",
"```{index} LIDAR, Pose SLAM\n",
"```\n",
"```{index} pair: iterative closest points; ICP\n",
"```\n",
"```{index} pair: simultaneous localization and mapping; SLAM\n",
"```\n",
"In addition to cameras, a very popular sensor in autonomous driving is the LIDAR sensor. We develop the basic geometry of LIDAR sensors, and then present the iterative closest points (ICP) algorithm as a way to obtain relative pose measurements from successive LIDAR scans. This leads naturally to the problem of simultaneous localization and mapping or SLAM, a very popular topic in robotics. Here we cover the most basic version, *Pose SLAM*, which only needs relative pose measurements. \n",
"\n",
"In section 5 we look at motion primitives to do some motion planning on the road. Finally, in section 6, we discuss the basics of deep reinforcement learning."
"```{index} motion primitives\n",
"```\n",
"```{index} pair: deep reinforcement learning; DRL\n",
"```\n",
"We then look at motion primitives to do motion planning on the road, alongside polynomial and spline-based path planning. Finally, we discuss the basics of deep reinforcement learning with an autonomous driving example."
]
}
],
Expand Down
Loading

0 comments on commit c274e37

Please sign in to comment.