Visualizing Loss function

I am getting error of “tuple index out of range” for this line - “for j in range(J.shape[1]):” : what does this mean and how to resolve this?

Hello @aakritiaggarwal,

This error means the tuple J.shape has length less than 2, meaning there is only 1 element in your J.shape tuple. Without looking at your code, I will not be able to resolve it. Share it using Coding Blocks IDE.

Hello,


here is my git link to this code.

Hello @aakritiaggarwal,

In Section 5

t0 = np.linspace(-40,40,100) #<- I have changed here
t1 = np.linspace(40,120,100)#<- and here
t0,t1 = np.meshgrid(t0,t1)

You were creating the t0, t1 the wrong way. Try this and let us know if this worked.

Thanks

t0 = np.arange(-40,40,100) #<- I have changed here
t1 = np.arange(40,120,100)#<- and here

100 here represents the difference between 2 consecutive numbers, so in this case, 100 is not possible because from -40 to 40 there are in total 80 numbers.

And my mistake was -> to,t1 = np.meshgrid(t0,t1), instead of typing t0 i wrote to.

Thankyou!

Hello @aakritiaggarwal,

Actually i also changed arange to linspace. I missed that while mentioning the changes here. And totally missed the t0 and to. :smile:
Glad you found it there.

Hello @Manu-Pillai-1566551720093198

I am sorry I missed that change. And I am glad to know about the linespace concept.
Thankyou!