Def optimize() doubt

def optimize(w, b, X, Y, num_iterations=100, learning_rate=0.009, print_cost=False):

in this function why are number of iterations for learning the parameters set to 100 and how do we decide on the learning rate?

1 Like

The number of iterations is set to 100 so when we use this function and do not set any value for the number of iterations, it will use 100 (default value for that function). But if we set the number of iterations to something else, that new value will override the default value.

It is based on experiment. We try different values and see which one gives best results. Here, 0.009 is a default learning rate for optimize function. However, our testing code use different values. So, your code should not hard code any value.

1 Like

how does number of iterations affect model accuracy?

The number of iterations has a significant effect on model accuracy. Generally, increasing the number of iterations can lead to improvement in model accuracy up to a certain point. However, beyond that point, the model may start to overfit.

1 Like

It’s rather similar to how the cooking time affects the quality of a loaf of bread.