Assignment 4 Contour Maps

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Q.5 How to interpret contour maps?

Ans.
Contour maps are two-dimensional representations of three-dimensional landscapes
that use contour lines to represent the elevation of the land. The lines connect points
of equal elevation, creating a topographic map that can be used to interpret the
terrain. Here are some steps to help you interpret a contour map:

1. Understand the contour interval: Contour maps use a contour interval, which is the
vertical distance between each contour line. For example, if the contour interval is 10
meters, each contour line represents a change in elevation of 10 meters.

2. Identify the contour lines: Contour lines are the curved lines on the map that
represent a specific elevation. The lines that are closer together represent steeper
terrain, while lines that are farther apart represent flatter terrain.

3. Determine the direction of the slope: Contour lines that are closer together on the
top of a hill and farther apart on the bottom indicate a hill. Conversely, contour lines
that are closer together at the bottom of a valley and farther apart at the top indicate
a valley.

4. Identify the highest and lowest points: The highest point on a contour map is the
peak of a mountain or hill, where the contour lines form a closed circle around a high
point. The lowest point is typically a depression, such as a basin or valley, where the
contour lines form a closed circle around a low point.

5. Evaluate the terrain: By interpreting the contour map, you can gain a better
understanding of the terrain, such as its steepness, the presence of ridges or valleys,
and the locations of peaks and depressions. This information can be useful for a
variety of purposes, such as planning hiking or camping trips or designing
infrastructure projects like roads or pipelines.
Overall, interpreting contour maps requires some practice and familiarity with the
terrain, but with these basic steps, you can begin to understand the elevation and
features of the landscape represented by the map.

Let’s assume that my 3D Error surface looks like this from the front view,

The graph's x-axis shows the interaction between the two parameters w and b, which
are each represented by a single parameter called theta, while the y-axis shows the
error value. Imagine cutting this mistake surface into horizontal slices along the
vertical axis. The space between the two ellipses is not equal, as can be seen if you
look at the error surface from the top. The distance is greater on the left side and
smaller on the right. This is because the error surface's region with the steepest slope
corresponds to the area with the shortest distance between the two ellipses
highlighted in red.

Similarly, the longest distance between two ellipses marked in yellow


corresponds to the area where the slope is a bit gentle in the error surface.

The key takeaway from this analysis is,


● A small distance between the contours indicates a steep slope along that direction.
● A large distance between the contours indicates a gentle slope along that direction.
Using this intuition now we will see some 2D contour plots and understand how to
interpret them.
Let’s assume that we have a 2D contour plot of a 3D surface error surface as
shown below, now can you imagine what the 3D surface would look like?

Guess the 3D Surface


The darker the shade of red indicates higher the loss value and darker the shade of
blue indicates lower the loss value. For all the contour plots shown in this article, I
will be following the same color schema.

Every angled line you see in the contour plot represents one cut along the vertical
axis that means the error (loss value) is the same along the line. If you look at the
contour present at the extreme left side of the plot (marked with yellow in the below

figure) there are no other boundaries or contour surfaces towards the left side in
contrast to the right side where you can see a cluster of contour surfaces very close
to each other.
Contour Extremes
As there are no contours present on the left side I can say that the distance between
the two contours (contour marked with yellow and some other contour located far
away towards the left, if present) is very large because I can’t see any contour in the
vicinity. If the distance between the contours is large that means the slope in this area
is very gentle so this area in the 3D plot will be a flat region.

It is going to be a high flat region because the color is red that indicates the error
value in this area will be high. Similarly, if we look at the contour present at the right
extreme of the plot (marked with black in the below figure) there are no boundaries
towards the right side that means the slope in this area is also very gentle and it will
be a flat region, it will be a low flat region because the color in this region is blue that
indicates the error value in this area will be low

Look at the Middle Region


Now we look at the region between the two extremes (marked with purple in the above figure)
it indicates that we are transitioning from high flat region to low flat region and the transition
is very rapid. If you look at the contours present in this middle region they are very close to
each other, we know that if the distance between the contours is very less that means there is
a very steep slope between the contours.

Now let’s see how the 3D surface looks like,

We started from the high flat surface (dark red) and the loss value was constant for a long
time because the surface is flat. We are transitioning very rapidly from the dark red region to
the dark blue region because the slopes were very steep in this region. This is how we
interpret the contour maps and imagine how the 3D surface would look like from the
corresponding 2D surface.
We will see one more contour map for practice and then we will move onto visualize

gradient descent error surface.


Guess the 3D Surface
We will start with the corners of the plot and figure out where are the flat surfaces or
plateaus located and then we will figure out where the valleys are located. First, by looking
at the regions marked(with black) in the below plot we can see that the distance between the
contours is large that means the slope in these regions will be gentle and these are flat
surfaces.

Also, the shade difference between the corresponding contours is not large it means that they
are close to each other and the loss value is not decreasing that much decreasing between the

contours. These flat regions will be high regions because their color is coded in red that
indicates the error value will be high in these regions.
Now coming to the blue regions of the plot marked with yellow lines, the distance between
the contours is large that means the slope in these regions will be gentle and these will be flat
surfaces. The error value in these regions will be on the lower side because these are color-
coded in light blue. The white region in the plot indicates that when we are transitioning
from red to blue somewhere we hit the white color. The error value in the white region will
be medium it’s not high and not low.

The topology of this white region also is a flat plateau because the distance between the two
consecutive orange contours is large. Let’s see how the 3D surface would look like,

3D Surface
As we interpreted, we have the four plateaus at different heights based on the error value and
all of these four plateaus are rapidly converging into the valley (dark blue region) where the
error is minimum.

Visualize Gradient Descent on 2D contour Map


To generate the 3D gradient descent loss surface, I have taken some toy data and iterated
over all the data points for 1000 epochs and computed loss for different values of w and b.
Once I got the loss values for all possible combinations of w and b, I was able to generate an
animation that shows the gradient descent rule in action.
Gradient Descent Rule in Action (Animation)

The points at the bottom indicate the different combinations of w & b (parameters) and the
points on the contour indicate the loss value for the corresponding parameter values. By
looking at the 3D plot try to visualize how the 2D contour plot would look like, from the
gradient descent loss animation, you would have observed for the first few iterations while
the curve is still on the flat light red surface the updates are moving very slowly that means
we would expect the distance between the contours is large.

Once the curve reaches the edge of the plateau it rapidly converges into the dark blue valley

that means we would expect consecutive contours to be very close to each other. Now let’s
see how the 2D contour look like,
As expected in the region where the gradient descent curve starts, the distance between the
consecutive contours is large. Once the curve starts to move towards the dark blue region we
can see that the distance between consecutive contours is very small that indicates there is a
steep slope along that direction.

Now we will see an animation which shows how the gradient descent update moves on the

2D contour plot. That’s about it, this how we interpret contour plots.

You might also like