22.02.2024 Views

Daniel Voigt Godoy - Deep Learning with PyTorch Step-by-Step A Beginner’s Guide-leanpub

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Output

2.7421577700550976

Loss Surface

We have just computed the loss (2.74) corresponding to our randomly initialized

parameters (b = 0.49 and w = -0.13). What if we did the same for ALL possible

values of b and w? Well, not all possible values, but all combinations of evenly spaced

values in a given range, like:

# Reminder:

# true_b = 1

# true_w = 2

# we have to split the ranges in 100 evenly spaced intervals each

b_range = np.linspace(true_b - 3, true_b + 3, 101)

w_range = np.linspace(true_w - 3, true_w + 3, 101)

# meshgrid is a handy function that generates a grid of b and w

# values for all combinations

bs, ws = np.meshgrid(b_range, w_range)

bs.shape, ws.shape

Output

((101, 101), (101, 101))

The result of the meshgrid() operation was two (101, 101) matrices representing

the values of each parameter inside a grid. What does one of these matrices look

like?

bs

32 | Chapter 0: Visualizing Gradient Descent

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!