# Can NUTS work with stochastic gradient / mini-batch?

**URL:** <https://discourse.pymc.io/t/can-nuts-work-with-stochastic-gradient-mini-batch/3182>\
**Category:** Questions\
**Created:** [May 1, 2019, 4:54pm UTC](https://discourse.pymc.io/t/can-nuts-work-with-stochastic-gradient-mini-batch/3182 "2019-05-01T16:54:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hamster\_on\_wheels](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/hamster_on_wheels/32/1823_2.png) [@Hamster\_on\_wheels](https://discourse.pymc.io/u/Hamster_on_wheels)\
**Post date:** [May 1, 2019, 4:54pm UTC](https://discourse.pymc.io/t/can-nuts-work-with-stochastic-gradient-mini-batch/3182/1 "2019-05-01T16:54:07Z")

</div>

Hi. I have just started to learn how to use pymc3.

Can NUTS of pymc3 work with stochastic gradient?

I am thinking about creating a new theano operation that provides a noisy estimation of the gradient and value of the potential energy function. That means when NUTS ask my operation for the gradient for the same point twice, NUTS can get two different values.

Can NUTS work in this case ?

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![Hamster\_on\_wheels](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/hamster_on_wheels/32/1823_2.png) [@Hamster\_on\_wheels](https://discourse.pymc.io/u/Hamster_on_wheels)\
**Post date:** [May 2, 2019, 3:20pm UTC](https://discourse.pymc.io/t/can-nuts-work-with-stochastic-gradient-mini-batch/3182/2 "2019-05-02T15:20:36Z")

</div>

Probably not… unless the mini-batches are sufficiently large.

Might need an extra friction term to damp the noise introduced by mini-batch.

> [@Minibatch and NUTS](https://discourse.pymc.io/t/minibatch-and-nuts/1352):
>
> Am I correct in saying that the minibatch mode doesn’t work with NUTS?
