daknowles
daknowles

Reputation: 1430

Is it possible to get the hessian through a gamma function in theano?

b=T.fvector()
theano.gradient.hessian( T.gammaln(b).sum(), [b] )

gives an unnamed NotImplementedError. Since the equivalent code works fine with e.g. T.log instead of T.gammaln I guess theano just doesn't know the second derivation of gammaln?

Upvotes: 0

Views: 130

Answers (1)

nouiz
nouiz

Reputation: 5071

The grad of gammaln use psi. But we didn't implement the grad of psi.

You can implement the method grad() of the class Psi in the file theano/scalar/basic_scipy.py. This would make this case work.

This page of the documentation explain how to add a new Op in Theano and explain how to implement the grad() method: http://deeplearning.net/software/theano/extending/extending_theano.html

If you need help implementing this, using theano-dev mailing list is better suited then stackoverflow for ongoing discussion.

If you do it, it would be a great contribution to Theano.

Upvotes: 1

Related Questions