Is shared_randomstreams renamed or deleted?

I have been using theano.tensor.shared_randomstreams.RandomStreams. In the latest version of PyMC3 (v 3.11.0) which uses theano v1.1.2, I get an error

module 'theano.tensor' has no attribute 'shared_randomstreams'

Did shared_randomstreams get renamed? Deleted?

The release notes for aesara 1.0.13 may be related?

A new RandomVariable Op that replaces RandomStreams and RandomFunction

1 Like


Thank you for improving Aesara (né: Theano) the last few months. I look forward to trying out the new Jax capabilities.

My model uses the old RandomStreams in the following way:

foo = tt.shared_randomstreams.RandomStreams(seed=seed)
count = foo.binomial(n=total, p=prob)

where total and prob are RVs with big shapes.

This usage was part of the model intended to only be defined for posterior predictive, using @lucianopaz’s model factory idiom. It works fine in PyMC3 3.9.3, but when run in v3.11.0, tt.shared_randomstreams.RandomStreams is no longer found.

Following the relevant documentation, I replaced the above with:

foo = tt.random.utils.RandomStream(seed=seed)
count = foo.binomial(n=total, p=prob)

But that substitution results in a TypeError. It looks like foo.binomial is creating (and sampling from) a BinomialRV, which is not what is needed here. The model just needs a binomial tensor created.

So it appears I need something else rather than tt.random.utils.RandomStream. Or perhaps I am jumping the gun, trying to use PyMC 3.11.0 before it is ready.


If you remove the keywords, it should work (i.e. foo.binomial(total, prob)).

These new random variables should have arguments that match the numpy.random[.RandomState] interface (in order at the very least), and–if they don’t–create an issue in the Aesara repo. In this instance, there’s a case to be made for allowing keyword arguments, but I’m not sure that’s a real priority right now.


Works. Thanks.