提交 85dbd796 authored 作者: Olivier Breuleux's avatar Olivier Breuleux

added a few more ways to draw random numbers

上级 8022ce3e
...@@ -91,8 +91,13 @@ def random_function(fn, dtype, *rfargs, **rfkwargs): ...@@ -91,8 +91,13 @@ def random_function(fn, dtype, *rfargs, **rfkwargs):
return f return f
uniform = random_function(numpy.random.RandomState.uniform, 'float64', 0.0, 1.0) RS = numpy.random.RandomState
# we need to provide defaults for all the functions in order to infer the argument types...
uniform = random_function(RS.uniform, 'float64', 0.0, 1.0)
binomial = random_function(RS.binomial, 'int64', 1, 0.5)
normal = random_function(RS.normal, 'float64', 0.0, 1.0)
random_integers = random_function(RS.random_integers, 'int64', 0, 1)
# T = tensor # T = tensor
...@@ -107,6 +112,17 @@ uniform = random_function(numpy.random.RandomState.uniform, 'float64', 0.0, 1.0) ...@@ -107,6 +112,17 @@ uniform = random_function(numpy.random.RandomState.uniform, 'float64', 0.0, 1.0)
# print f(numpy.random.RandomState(1000), [[-1, -1], [-10, -10]], [[10, 1], [10, 1]]) # print f(numpy.random.RandomState(1000), [[-1, -1], [-10, -10]], [[10, 1], [10, 1]])
# T = tensor
# import compile
# r = gof.generic()
# shp = (2, 7)
# r2, z = binomial(r, shp)
# f = compile.function([r], [z])
# print f(numpy.random.RandomState(1000))
@gof.local_optimizer @gof.local_optimizer
def random_make_inplace(node): def random_make_inplace(node):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论