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