educative.io

Educative

https://www.educative.io/courses/deep-learning-pytorch-fundamentals/NEpopWOrmRz

But there are 101 values then how it can be 100 intervals ? Could you please elaborate this ?

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)


Course: Deep Learning with PyTorch Step-by-Step: Part I - Fundamentals - Learn Interactively
Lesson: Step 2b - Computing the Loss Surface - Deep Learning with PyTorch Step-by-Step: Part I - Fundamentals

@Ammar_Ahmad_Farid Could you also respond to this one please? I’ve seen that you’ve answered an another query which is related to this topic only

@Ammar_Ahmad_Farid and @Javeria_Tariq Do you mind responding to my query please?


Course: https://www.educative.io/courses/beginners-guide-to-deep-learning
Lesson: Educative: Interactive Courses for Software Developers

Hi @Vikrant !!
When the statement says “we have to split the ranges in 100 evenly spaced intervals each,” it means that the ranges for both b and w are divided into 100 intervals. However, there will be 101 values in total because an interval includes both its start and end points.

Let’s break it down step by step using the given code:

# Reminder:
true_b = 1
true_w = 2

# We want to create a range of values for b and w, each spanning from true value - 3 to true value + 3.
# We want 100 intervals for each range.

# Create an array of 101 evenly spaced values for b, ranging from true_b - 3 to true_b + 3.
b_range = np.linspace(true_b - 3, true_b + 3, 101)

# Create an array of 101 evenly spaced values for w, ranging from true_w - 3 to true_w + 3.
w_range = np.linspace(true_w - 3, true_w + 3, 101)

In this code, the linspace function generates an array of evenly spaced values within a specified range. The parameters are (start, stop, num), where start is the starting value, stop is the ending value, and num is the number of points (or intervals) to generate.

So, in the case of b_range and w_range, we want 100 intervals, and thus we specify num=101. The reason for num=101 is that if we want 100 intervals, we need 101 points to define those intervals (since an interval includes both its endpoints).

As a result, you get arrays b_range and w_range, each containing 101 values that span the specified ranges with 100 intervals. This allows you to create a grid of all possible combinations of b and w values to explore the loss surface.
I hope this helps. Happy Learning :blush:

1 Like