Technically, any function with a signature like the ones in numpy.random.RandomState
will do. This function must accept the shape (sometimes called size) of the output as
the last positional argument.
Technically, any function with a signature like the ones in
numpy.random.RandomState will do. This function must accept
the shape (sometimes called size) of the output as the last
positional argument.
:type fn: string or function reference. A string will be interpreted as the name of a
member function of numpy.random.RandomState.
:type fn: string or function reference. A string will
be interpreted as the name of a member function of
numpy.random.RandomState.
:param outtype: the theano Type of the output
...
...
@@ -96,8 +99,6 @@ class RandomFunction(gof.Op):
self.fn=getattr(numpy.random.RandomState,fn)
else:
self.fn=fn
#backport
#self.fn = getattr(numpy.random.RandomState, fn) if isinstance(fn, str) else fn
self.outtype=outtype
self.inplace=inplace
ifself.inplace:
...
...
@@ -162,9 +163,10 @@ class RandomFunction(gof.Op):
asserttype(r)==numpy.random.RandomState
r_orig=r
# If shape == [], that means numpy will compute the correct shape,
# numpy uses shape "None" to represent that. Else, numpy expects a tuple.
# TODO: compute the appropriate shape?
# If shape == [], that means no shape is enforced, and numpy is
# trusted to draw the appropriate number of samples, numpy uses
# shape "None" to represent that. Else, numpy expects a tuple.
# TODO: compute the appropriate shape, and pass it to numpy.
iflen(shape)==0:
shape=None
else:
...
...
@@ -200,7 +202,6 @@ class RandomFunction(gof.Op):
raiseValueError('Shape mismatch: "out" should have shape starting with %s (plus %i extra dimensions), but the value produced by "perform" has shape %s'\