Exercise 4 - dLdOmega_of_omega_array() (C2_W1_Assignment)

I am calling the grad function with the L_of_omega_array and then passing omega_array[i] to the function returned. first time through the loop gets n tuple index out of range (please see below).

Thanks

IndexError Traceback (most recent call last)
File /opt/conda/lib/python3.8/site-packages/jax/core.py:1427, in ShapedArray._len(self, ignored_tracer)
1426 try:
→ 1427 return self.shape[0]
1428 except IndexError as err:

IndexError: tuple index out of range

The above exception was the direct cause of the following exception:

TypeError Traceback (most recent call last)
Cell In [58], line 23
20 print(“end of loop”)
21 return dLdOmega_array
→ 23 dLdOmega_array = dLdOmega_of_omega_array(omega_array)

Hi,

As far as I can see, you are passing the same function you are building. Even though this is not a problem, recursion is not needed and not expected in this solution. How do you define dLdOmega in the function?

i may have been doing that. someone suggested looking at the hint (duh) and i was able to fix it. thanks

it might be helpful to point out that the usage of grad, for a function f1, evaluated at the point x=5, would be jax.grad(f1)(5.0)