Autograd "ValueError: setting an array element with a sequence" when computing norm.logpdf partial derivative

18 Views Asked by At

I am trying to compute the partial derivative of the log pdf of a normal distribution with autograd as in the following code :

import autograd.scipy.stats as stat 
import autograd.numpy as np
from autograd import grad

def f(x, lc, sc):
    return stat.norm.logpdf(x, loc= lc, scale = sc)

grad_f = grad(f, argnum=1)

grad_f(-1.0, 1.)

and I get the following error message :

"ValueError: setting an array element with a sequence".

I believe that autograd knows how to handle gradients of the norm.logpdf since it is an in-built function and no other vector assignments have been made...

0

There are 0 best solutions below