I’m implementing a neural network using pytorch. My loss function is a custom negative log likelihood which is easy to implement using pyro plate. How can I incorporate this loss into pytorch?

# Custom log likelihood

How can I incorporate this loss into pytorch?

do you mean pyro? check out the tutorial on how to build custom objectives. if you just want to incorporate an additional likelihood term you can `observe`

from a `Delta`

(by specifying `log_density`

) or `Bernoulli`

.

I meant pytorch. My neural network is in pytorch. But it’s difficult to implement a custom negative log likelihood as loss in pytorch. It can be easily done in pyro using pyro.plate. But pyro uses it inside model. I’m not sure if there is a way to use pyro.plate inside a pytorch neural network model.

Thanks.

i think you may be confused. pytorch is just python - you can construct any algebraic expression and call `backward()`

… pyro is implemented using pytorch… perhaps check out the pytorch tutorials or post on their forum?

Thanks will try to do that. It’s just that using pyro.plate I can implement custom multivariate distributions easily. Unlike pytorch where Independent assumes each dimension has the same distribution (for example all independent dimensions are Normal ).