Explain Visualizing cost function


Can anybody explain what andrew explained in the video , I have understood the previous video when b = 0, but with b the cost function and it’s graph are a bit complicated, please help me through this.

I can try to answer if you ask a more specific question. What exactly about the lecture did you not understand?

Hi @pydithalli_naidu these topics can be challenging at first, my suggestion is to re-watch the video and put everything you can into notes and try to find analogies, even ask chatGPT to explain in simple terms to a 9-year-old (I use this a lot) to understand the intuition behind the concept. If you still find it hard to understand you can always ask what areas are you struggling and we will try to answer them.

I hope this helps!

It’s just the same thing… finding the local minimum for the cost function.

For the case, when b=0, you’re only finding the minimum J with respect to the weight w, so you have a 2-dimension graph and you look at point where the graph is minimum

This is the same thing for the slide you’re referenced above - expect that now you need to optimize J with respect to b and W (since b isnt 0 and can vary). So the graph looks 3-dimensional, since you have w,b and j

for this 3-d graph, to find the minimum you also look at the lowest point in the 3-d image, but now we reference a contour plot. That means at the top right pic, we look at the lowest point which is the middle circle.

1 Like

**In this lecture, we studied about the cost function with the multiple parameter’s. While, in the previous lecture we have seen the cost function with the single perimeter that was so simple because there we have only one parameter that is “w”.
By using 2-dimensional graph we have seen that.
Now, in this cost function we are using the multiple parameters to see the behavior’s of cost function how it’s work?
That’s way we are here using a three-dimensional graph where horizontal axis show the input features and vertical axis show the cost that is J(w,b).
The top left graph is showing the data where we try to fit the best line that help to find the perfect predictions.
Basically the cost function helps to check how well our model is working. the counter plot graph helps us to see the global minimum. Basically the global minimum is the point where over cost function is approximately close to zero. if over cost function is close to zero that mean why we have build a model that works best with unseen data.
And other main thing is that cost function show that how a particular predictions are differs from the actual target value.
I hope you will understand if you have any query you can ask freely thankyou!!

1 Like

the lines in the top left graph indicates different f(x) which are pretty bad predictions but they have the same J value because they are at the same height right?

The cost can be seen from either the contour plot or the 3d surface plot. The top left plot just shows how well your model i.e. your f_wb is fitting the training data. In the contour plot and in the surface plot, we see that costs(orange, blue, green cross marks) are different for respective w and b. They are not at the same height. Hope I answered your question!

But in the video he said they are at the same height, maybe I am wrong …I will watch it once more to get clarity. anyway thank you:)

Please post the video title and time mark.

The cost for the three lines is same becuase they are on the same oval or ellipse for different values of w and b and they have same height from the surface

When we cut the contour plot horizontally like a slices, Assume we are calculating J(w,b) for three different values of w and b and the cost for J(w,b) is same meaning they are on the same slice right? And also we can assume that they have the same height from surface. I think this is what he said in the video
Am I correct?

What “three lines” are you referring to? Please be specific.

I am referring to the cost of the orange, green and blues lines

Your statement is true for the upper right figure (the contour plot) and for the 3D plot at the bottom.

@TMosh - In the contour plot above, I see that the costs for 3 models (green, blue, and orange cross marks) represent different values for their respective w and b. How are we saying that the costs are at the same height? Cuz even the dotted lines from those costs seem to be of different lengths right?

The dotted lines in the upper-right plot do not show the magnitude of the cost - they show what the w and b values are for that point in the grid.

The length of the lines in the ‘z’ axis of the 3D plot show the cost.

I am only available here.