Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c5331121
提交
c5331121
authored
1月 20, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs: more work on random docs
上级
134658d7
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
92 行增加
和
50 行删除
+92
-50
raw_random.txt
doc/library/tensor/raw_random.txt
+79
-24
shared_randomstreams.txt
doc/library/tensor/shared_randomstreams.txt
+13
-24
raw_random.py
theano/tensor/raw_random.py
+0
-2
没有找到文件。
doc/library/tensor/raw_random.txt
浏览文件 @
c5331121
...
@@ -21,30 +21,16 @@ Reference
...
@@ -21,30 +21,16 @@ Reference
A `Type` for variables that will take ``numpy.random.RandomState`` values.
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_variable``.
.. class:: RandomFunction(gof.Op)
.. class:: RandomFunction(gof.Op)
Op that draws random numbers from a numpy.RandomState object. This Op is
Op that draws random numbers from a numpy.RandomState object. This Op is
parametrized to draw numbers from many possible distributions.
parametrized to draw numbers from many possible distributions.
.. function:: uniform(random_state, size=(), low=0.0, high=1.0)
.. function:: random_function(fn, dtype, *rfargs, **rfkwargs)
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
number of dimensions.
If the distribution is not scalar (e.g., a multinomial), the output will have
more dimensions than what the shape argument suggests. The "ndim_added" keyword
arguments allows to specify how many dimensions to add (for a multinomial, 1).
The number of dimensions for the following shape arguments can be inferred:
* shape(x)
* make_lvector(x, y, z, ...)
* ndarrays, constants
.. function:: uniform(random_state, size, low=0.0, high=1.0)
Sample from a uniform distribution between low and high.
Sample from a uniform distribution between low and high.
...
@@ -54,7 +40,7 @@ Reference
...
@@ -54,7 +40,7 @@ Reference
:returns: :class:`RandomVariable`, NewRandomState
:returns: :class:`RandomVariable`, NewRandomState
.. function:: binomial(random_state, size, n=1, p=0.5)
.. function:: binomial(random_state, size
=()
, n=1, p=0.5)
Sample n times with probability of success prob for each trial,
Sample n times with probability of success prob for each trial,
return the number of successes.
return the number of successes.
...
@@ -64,7 +50,7 @@ Reference
...
@@ -64,7 +50,7 @@ Reference
to supplement the missing information.
to supplement the missing information.
:returns: :class:`RandomVariable`, NewRandomState
:returns: :class:`RandomVariable`, NewRandomState
.. function:: normal(random_state, size, avg=0.0, std=1.0)
.. function:: normal(random_state, size
=()
, avg=0.0, std=1.0)
Sample from a normal distribution centered on avg with
Sample from a normal distribution centered on avg with
the specified standard deviation (std)
the specified standard deviation (std)
...
@@ -75,7 +61,7 @@ Reference
...
@@ -75,7 +61,7 @@ Reference
:returns: :class:`RandomVariable`, NewRandomState
:returns: :class:`RandomVariable`, NewRandomState
.. function:: random_integers(random_state, size, low=0, high=1)
.. function:: random_integers(random_state, size
=()
, low=0, high=1)
Sample a random integer between low and high, both inclusive.
Sample a random integer between low and high, both inclusive.
...
@@ -85,7 +71,7 @@ Reference
...
@@ -85,7 +71,7 @@ Reference
:returns: :class:`RandomVariable`, NewRandomState
:returns: :class:`RandomVariable`, NewRandomState
.. function:: permutation(random_state, size, n=1)
.. function:: permutation(random_state, size
=()
, n=1)
Returns permutations of the integers between 0 and n-1, as many times
Returns permutations of the integers between 0 and n-1, as many times
as required by size. For instance, if size=(p,q), p*q permutations
as required by size. For instance, if size=(p,q), p*q permutations
...
@@ -98,7 +84,7 @@ Reference
...
@@ -98,7 +84,7 @@ Reference
:returns: :class:`RandomVariable`, NewRandomState
:returns: :class:`RandomVariable`, NewRandomState
.. function:: multinomial(random_state, size, p_vals=[0.5, 0.5])
.. function:: multinomial(random_state, size
=()
, p_vals=[0.5, 0.5])
Sample from a multinomial distribution defined by probabilities pvals,
Sample from a multinomial distribution defined by probabilities pvals,
as many times as required by size. For instance, if size=(p,q), p*q
as many times as required by size. For instance, if size=(p,q), p*q
...
@@ -110,3 +96,72 @@ Reference
...
@@ -110,3 +96,72 @@ Reference
:returns: :class:`RandomVariable`, NewRandomState
:returns: :class:`RandomVariable`, NewRandomState
.. class:: RandomStreamsBase(object)
.. method:: binomial(self, size=(), n=1, prob=0.5, ndim=None):
Sample n times with probability of success prob for each trial, return the number of
successes.
If the size argument is ambiguous on the number of dimensions, the first argument may be a
plain integer to supplement the missing information.
.. method:: uniform(self, size=(), low=0.0, high=1.0, ndim=None):
Sample a tensor of given size whose element from a uniform distribution between low and high.
If the size argument is ambiguous on the number of
dimensions, the first argument may be a plain integer
to supplement the missing information.
.. method:: normal(self, size=(), avg=0.0, std=1.0, ndim=None):
Usage: normal(random_state, size,
Sample from a normal distribution centered on avg with
the specified standard deviation (std)
If the size argument is ambiguous on the number of
dimensions, the first argument may be a plain integer
to supplement the missing information.
.. method:: random_integers(self, size=(), low=0, high=1, ndim=None):
Usage: random_integers(random_state, size, low=0, high=1)
Sample a random integer between low and high, both inclusive.
If the size argument is ambiguous on the number of
dimensions, the first argument may be a plain integer
to supplement the missing information.
.. method:: permutation(self, size=(), n=1, ndim=None):
Returns permutations of the integers between 0 and n-1, as many times
as required by size. For instance, if size=(p,q), p*q permutations
will be generated, and the output shape will be (p,q,n), because each
permutation is of size n.
Theano tries to infer the number of dimensions from the length of the size argument, but you
may always specify it with the `ndim` parameter.
.. note::
Note that the output will then be of dimension ndim+1.
.. method:: multinomial(self, size=(), n=1, pvals=[0.5, 0.5], ndim=None):
Sample n times from a multinomial distribution defined by probabilities pvals,
as many times as required by size. For instance, if size=(p,q), p*q
samples will be drawn, and the output shape will be (p,q,len(pvals)).
Theano tries to infer the number of dimensions from the length of the size argument, but you
may always specify it with the `ndim` parameter.
.. note::
Note that the output will then be of dimension ndim+1.
.. method:: shuffle_row_elements(self, input):
Return a variable with every row (rightmost index) shuffled.
This uses permutation random variable internally, available via the ``.permutation``
attribute of the return value.
doc/library/tensor/shared_randomstreams.txt
浏览文件 @
c5331121
...
@@ -101,10 +101,11 @@ For example:
...
@@ -101,10 +101,11 @@ For example:
Reference
Reference
=========
=========
.. class:: RandomStreams(
object
)
.. class:: RandomStreams(
raw_random.RandomStreamsBase
)
This is a symbolic stand-in for ``numpy.random.RandomState``. It has
This is a symbolic stand-in for ``numpy.random.RandomState``.
methods such as `uniform` and `normal` that return symbolic random variables.
Random variables of various distributions are instantiated by calls to
parent class :class:`raw_random.RandomStreamsBase`.
.. method:: updates()
.. method:: updates()
...
@@ -118,34 +119,22 @@ Reference
...
@@ -118,34 +119,22 @@ Reference
`meta_seed` will be used to seed a temporary random number generator,
`meta_seed` will be used to seed a temporary random number generator,
that will in turn generate seeds for each of the random variables that
that will in turn generate seeds for each of the random variables that
has been created by this object.
has been created by this object
(via `gen`)
.
:returns: None
:returns: None
.. method::
binomial(self, size, n=1, p=0.5
)
.. method::
gen(op, *args, **kwargs
)
Symbolic stand-in for numpy.random.RandomState.binomial
Return the random variable from `op(*args, **kwargs)`, but
also install special attributes (``.rng`` and ``update``, see
:class:`RandomVariable` ) into it.
:returns: :class:`RandomVariable` of float64 that will have `shape==size` at run-time.
This function also adds the returned variable to an internal list so
that it can be seeded later by a call to `seed`.
.. method:: uniform(self, size, low=0.0, high=1.0)
.. method:: uniform, normal, binomial, multinomial, random_integers, ...
Symbolic stand-in for numpy.random.RandomState.uniform
:returns: :class:`RandomVariable` of float64 that will have `shape==size` at run-time.
.. method:: normal(self, size, loc=0.0, std=1.0)
Symbolic stand-in for numpy.random.RandomState.normal
:returns: :class:`RandomVariable` of float64 that will have `shape==size` at run-time.
.. method:: random_integers(self, size, low=0, high=1)
Symbolic stand-in for numpy.random.RandomState.random_integers
:returns: :class:`RandomVariable` of int64 that will have `shape==size` at run-time.
See :class:`raw_random.RandomStreamsBase`.
.. class:: RandomVariable(object)
.. class:: RandomVariable(object)
...
...
theano/tensor/raw_random.py
浏览文件 @
c5331121
...
@@ -236,7 +236,6 @@ def normal(random_state, size=(), avg=0.0, std=1.0, ndim=None):
...
@@ -236,7 +236,6 @@ def normal(random_state, size=(), avg=0.0, std=1.0, ndim=None):
tensor
.
TensorType
(
dtype
=
'float64'
,
broadcastable
=
(
False
,)
*
ndim
)
)
tensor
.
TensorType
(
dtype
=
'float64'
,
broadcastable
=
(
False
,)
*
ndim
)
)
return
op
(
random_state
,
size
,
avg
,
std
)
return
op
(
random_state
,
size
,
avg
,
std
)
def
random_integers
(
random_state
,
size
=
(),
low
=
0
,
high
=
1
,
ndim
=
None
):
def
random_integers
(
random_state
,
size
=
(),
low
=
0
,
high
=
1
,
ndim
=
None
):
"""
"""
Usage: random_integers(random_state, size, low=0, high=1)
Usage: random_integers(random_state, size, low=0, high=1)
...
@@ -278,7 +277,6 @@ def permutation_helper(random_state, n, shape):
...
@@ -278,7 +277,6 @@ def permutation_helper(random_state, n, shape):
print
'RETURNING'
,
out
.
shape
print
'RETURNING'
,
out
.
shape
return
out
return
out
def
permutation
(
random_state
,
size
=
(),
n
=
1
,
ndim
=
None
):
def
permutation
(
random_state
,
size
=
(),
n
=
1
,
ndim
=
None
):
"""
"""
Returns permutations of the integers between 0 and n-1, as many times
Returns permutations of the integers between 0 and n-1, as many times
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论