def hessian_diag1(f, v): g = gradient1(f, v) idx = tt.arange(g.shape[0], dtype='int32') def hess_ii(i): return gradient1(g[i], v)[i] return theano.map(hess_ii, idx)[0]
def jacobian1(f, v): """jacobian of f wrt v""" f = tt.flatten(f) idx = tt.arange(f.shape[0]) def grad_i(i): return gradient1(f[i], v) return theano.map(grad_i, idx)[0]
def hessian_diag1(f, v): g = gradient1(f, v) idx = t.arange(g.shape[0]) def hess_ii(i): return gradient1(g[i], v)[i] return theano.map(hess_ii, idx)[0]
def jacobian1(f, v): """jacobian of f wrt v""" f = t.flatten(f) idx = t.arange(f.shape[0]) def grad_i(i): return gradient1(f[i], v) return theano.map(grad_i, idx)[0]