Skip to content

Incorrect history in 03_gradient/plot_loss_with_path.py? #1

@skoe

Description

@skoe

First of all, thanks for the great book and for keeping the code up to date! There seems to be a bug in 03_gradient/plot_loss_with_path.py, if I understood everything correctly.

The history path should be on the surface, because the gradient descent moves along the surface, right? When I rotate the diagram, the line floats partly over the surface and has two direction changes.

Figure_1

I couldn't understand that. If I change the code like this:

         current_loss = loss(X, Y, w, b)
-        history.append([w, b, previous_loss])
+        history.append([w, b, current_loss])

Figure_2

Now the line lies on the surface, it only has one kink and now actually seems to follow the steepest descent in each case. It also makes sense according to my understanding, because we want to plot the loss that belongs to w, b not the loss that belonged to the previous w and previous b. Is that correct? If so, perhaps you can put this corrections (and others, if any) in a README in the appropriate directory?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions