Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new RandomVariable Op and optimizations #137

Merged
4 changes: 2 additions & 2 deletions doc/library/scan.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ the following:
bvis = theano.shared(bvis_values)
bhid = theano.shared(bhid_values)

trng = tt.shared_randomstreams.RandomStreams(1234)
trng = tt.random.utils.RandomStream(1234)

def OneStep(vsample) :
hmean = tt.nnet.sigmoid(theano.dot(vsample, W) + bhid)
Expand Down Expand Up @@ -354,7 +354,7 @@ updated:
bvis = theano.shared(bvis_values)
bhid = theano.shared(bhid_values)

trng = tt.shared_randomstreams.RandomStreams(1234)
trng = tt.random.utils.RandomStream(1234)

# OneStep, with explicit use of the shared variables (W, bvis, bhid)
def OneStep(vsample, W, bvis, bhid):
Expand Down
7 changes: 3 additions & 4 deletions doc/library/tensor/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
:synopsis: symbolic types and operations for n-dimensional arrays.
.. moduleauthor:: LISA

Theano's strength is in expressing symbolic calculations involving tensors.
There are many types of symbolic expressions for tensors.
Theano's strength is in expressing symbolic calculations involving tensors.
There are many types of symbolic expressions for tensors.
They are grouped into the following sections:


Expand All @@ -19,8 +19,7 @@ They are grouped into the following sections:

basic
nnet/index
raw_random
shared_randomstreams
random/index
signal/index
utils
elemwise
Expand Down
45 changes: 45 additions & 0 deletions doc/library/tensor/random/basic.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

.. _libdoc_tensor_random:

=============================================
:mod:`random` -- Low-level random numbers
=============================================

.. module:: theano.tensor.random
:synopsis: symbolic random variables
.. moduleauthor:: pymc-team


The `theano.tensor.random` module provides random-number drawing functionality
that closely resembles the `numpy.random` module.

Reference
=========

.. class:: RandomStream()

A helper class that tracks changes in a shared ``numpy.random.RandomState``
and behaves like ``numpy.random.RandomState`` by managing access
to `RandomVariable`s. For example:

.. testcode:: constructors

from theano.tensor.random.utils import RandomStream

rng = RandomStream()
sample = rng.normal(0, 1, size=(2, 2))

.. class:: RandomStateType(gof.Type)

A `Type` for variables that will take ``numpy.random.RandomState``
values.

.. function:: random_state_type(name=None)

Return a new Variable whose ``.type`` is ``random_state_type``.

.. class:: RandomVariable(gof.Op)

`Op` that draws random numbers from a `numpy.random.RandomState` object.
This `Op` is parameterized to draw numbers from many possible
distributions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.. _libdoc_tensor_shared_randomstreams:
.. _libdoc_tensor_random_utils:

======================================================
:mod:`shared_randomstreams` -- Friendly random numbers
:mod:`utils` -- Friendly random numbers
======================================================

.. module:: theano.tensor.shared_randomstreams
.. module:: theano.tensor.random.utils
:platform: Unix, Windows
:synopsis: symbolic random variables
.. moduleauthor:: LISA
Expand All @@ -27,17 +27,15 @@ For an example of how to use random numbers, see
Reference
=========

.. class:: RandomStreams(raw_random.RandomStreamsBase)
.. class:: RandomStream()

This is a symbolic stand-in for ``numpy.random.RandomState``.
Random variables of various distributions are instantiated by calls to
parent class :class:`raw_random.RandomStreamsBase`.
This is a symbolic stand-in for ``numpy.random.RandomState``.

.. method:: updates()

:returns: a list of all the (state, new_state) update pairs for the
random variables created by this object

This can be a convenient shortcut to enumerating all the random
variables in a large graph in the ``update`` parameter of function.

Expand All @@ -60,21 +58,4 @@ Reference

.. method:: uniform, normal, binomial, multinomial, random_integers, ...

See :class:`raw_random.RandomStreamsBase`.

.. class:: RandomVariable(object)

.. attribute:: rng

The shared variable whose ``.value`` is the numpy RandomState
generator feeding this random variable.

.. attribute:: update

A pair
whose first element is a shared variable whose value is a numpy RandomState,
and whose second element is an [symbolic] expression for the next value of that
RandomState after drawing samples.
Including this pair in the``updates`` list to function will cause the
function to update the random number generator feeding this variable.

See :class:`basic.RandomVariable`.
215 changes: 0 additions & 215 deletions doc/library/tensor/raw_random.txt

This file was deleted.

2 changes: 1 addition & 1 deletion doc/nextml2015/presentation.tex
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ \subsection{Scan}
b_sym = tt.vector("b_sym")

# define shared random stream
trng = tt.shared_randomstreams.RandomStreams(1234)
trng = tt.random.utils.RandomStream(1234)
d=trng.binomial(size=W[1].shape)
\end{lstlisting}
\end{frame}
Expand Down
Loading