提交 f39f3d69 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Fix the ability to specify a number of dimension as first argument of a random

distribution.
上级 3f596d97
......@@ -199,9 +199,9 @@ def __oplist_tag(thing, tag):
def random_function(fn, dtype, *rfargs, **rfkwargs):
"""
Returns a wrapper around RandomFunction which automatically infers the number
Returns a wrapper around RandomFunction which automatically infers the number
of dimensions of the output from the given shape. If the shape cannot be inferred,
the user can give an integer as first argument, which will be interpreted as the
the user can give an integer as first argument, which will be interpreted as the
number of dimensions.
The number of dimensions for the following shape arguments can be inferred:
......@@ -210,11 +210,12 @@ def random_function(fn, dtype, *rfargs, **rfkwargs):
- constants
"""
@constructor
def f(ndim, *args, **kwargs):
def f(r, ndim, *args, **kwargs):
print 'f(', ndim, args, ')'
if isinstance(ndim, int):
r, shape, args = args[0], args[1], args[2:]
shape, args = args[0], args[1:]
else:
r, shape, args = ndim, args[0], args[1:]
shape = ndim
if shape == () or shape == []:
shape = tensor.TensorConstant(type = tensor.lvector, data = shape)
else:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论