Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
3259dafa
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3259dafa
编写于
8月 19, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
8月 19, 2020
浏览文件
操作
浏览文件
下载
差异文件
!4712 Fix bugs in random ops
Merge pull request !4712 from peixu_ren/custom_pp_ops
上级
6868b9b6
2830d704
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
23 deletion
+17
-23
mindspore/ops/composite/random_ops.py
mindspore/ops/composite/random_ops.py
+7
-13
mindspore/ops/operations/random_ops.py
mindspore/ops/operations/random_ops.py
+10
-10
未找到文件。
mindspore/ops/composite/random_ops.py
浏览文件 @
3259dafa
...
@@ -35,12 +35,12 @@ def set_seed(seed):
...
@@ -35,12 +35,12 @@ def set_seed(seed):
random seed.
random seed.
Args:
Args:
seed(Int): the graph-level seed value that to be set.
seed(Int): the graph-level seed value that to be set.
Must be non-negative.
Examples:
Examples:
>>> C.set_seed(10)
>>> C.set_seed(10)
"""
"""
const_utils
.
check_
int_posi
tive
(
"seed"
,
seed
,
"set_seed"
)
const_utils
.
check_
non_nega
tive
(
"seed"
,
seed
,
"set_seed"
)
global
_GRAPH_SEED
global
_GRAPH_SEED
_GRAPH_SEED
=
seed
_GRAPH_SEED
=
seed
...
@@ -56,7 +56,7 @@ def get_seed():
...
@@ -56,7 +56,7 @@ def get_seed():
Interger. The current graph-level seed.
Interger. The current graph-level seed.
Examples:
Examples:
>>> C.get_seed(
10
)
>>> C.get_seed()
"""
"""
return
_GRAPH_SEED
return
_GRAPH_SEED
...
@@ -70,7 +70,7 @@ def normal(shape, mean, stddev, seed=0):
...
@@ -70,7 +70,7 @@ def normal(shape, mean, stddev, seed=0):
With float32 data type.
With float32 data type.
stddev (Tensor): The deviation σ distribution parameter. With float32 data type.
stddev (Tensor): The deviation σ distribution parameter. With float32 data type.
seed (int): Seed is used as entropy source for Random number engines generating pseudo-random numbers.
seed (int): Seed is used as entropy source for Random number engines generating pseudo-random numbers.
Default: 0.
Must be non-negative.
Default: 0.
Returns:
Returns:
Tensor. The shape should be the broadcasted shape of Input "shape" and shapes of mean and stddev.
Tensor. The shape should be the broadcasted shape of Input "shape" and shapes of mean and stddev.
...
@@ -107,7 +107,7 @@ def uniform(shape, a, b, seed=0, dtype=mstype.float32):
...
@@ -107,7 +107,7 @@ def uniform(shape, a, b, seed=0, dtype=mstype.float32):
It defines the maximum possibly generated value. With int32 or float32 data type.
It defines the maximum possibly generated value. With int32 or float32 data type.
If dtype is int32, only one number is allowed.
If dtype is int32, only one number is allowed.
seed (int): Seed is used as entropy source for Random number engines generating pseudo-random numbers.
seed (int): Seed is used as entropy source for Random number engines generating pseudo-random numbers.
Default: 0.
Must be non-negative.
Default: 0.
Returns:
Returns:
Tensor. The shape should be the broadcasted shape of Input "shape" and shapes of a and b.
Tensor. The shape should be the broadcasted shape of Input "shape" and shapes of a and b.
...
@@ -151,7 +151,7 @@ def gamma(shape, alpha, beta, seed=0):
...
@@ -151,7 +151,7 @@ def gamma(shape, alpha, beta, seed=0):
alpha (Tensor): The alpha α distribution parameter. With float32 data type.
alpha (Tensor): The alpha α distribution parameter. With float32 data type.
beta (Tensor): The beta β distribution parameter. With float32 data type.
beta (Tensor): The beta β distribution parameter. With float32 data type.
seed (int): Seed is used as entropy source for Random number engines generating pseudo-random numbers.
seed (int): Seed is used as entropy source for Random number engines generating pseudo-random numbers.
Default: 0.
Must be non-negative.
Default: 0.
Returns:
Returns:
Tensor. The shape should be the broadcasted shape of Input "shape" and shapes of alpha and beta.
Tensor. The shape should be the broadcasted shape of Input "shape" and shapes of alpha and beta.
...
@@ -163,10 +163,6 @@ def gamma(shape, alpha, beta, seed=0):
...
@@ -163,10 +163,6 @@ def gamma(shape, alpha, beta, seed=0):
>>> beta = Tensor(1.0, mstype.float32)
>>> beta = Tensor(1.0, mstype.float32)
>>> output = C.gamma(shape, alpha, beta, seed=5)
>>> output = C.gamma(shape, alpha, beta, seed=5)
"""
"""
alpha_dtype
=
F
.
dtype
(
alpha
)
beta_dtype
=
F
.
dtype
(
beta
)
const_utils
.
check_tensors_dtype_same
(
alpha_dtype
,
mstype
.
float32
,
"gamma"
)
const_utils
.
check_tensors_dtype_same
(
beta_dtype
,
mstype
.
float32
,
"gamma"
)
const_utils
.
check_non_negative
(
"seed"
,
seed
,
"gamma"
)
const_utils
.
check_non_negative
(
"seed"
,
seed
,
"gamma"
)
seed1
=
get_seed
()
seed1
=
get_seed
()
seed2
=
seed
seed2
=
seed
...
@@ -182,7 +178,7 @@ def poisson(shape, mean, seed=0):
...
@@ -182,7 +178,7 @@ def poisson(shape, mean, seed=0):
shape (tuple): The shape of random tensor to be generated.
shape (tuple): The shape of random tensor to be generated.
mean (Tensor): The mean μ distribution parameter. With float32 data type.
mean (Tensor): The mean μ distribution parameter. With float32 data type.
seed (int): Seed is used as entropy source for Random number engines generating pseudo-random numbers.
seed (int): Seed is used as entropy source for Random number engines generating pseudo-random numbers.
Default: 0.
Must be non-negative.
Default: 0.
Returns:
Returns:
Tensor. The shape should be the broadcasted shape of Input "shape" and shapes of mean.
Tensor. The shape should be the broadcasted shape of Input "shape" and shapes of mean.
...
@@ -193,8 +189,6 @@ def poisson(shape, mean, seed=0):
...
@@ -193,8 +189,6 @@ def poisson(shape, mean, seed=0):
>>> mean = Tensor(1.0, mstype.float32)
>>> mean = Tensor(1.0, mstype.float32)
>>> output = C.poisson(shape, mean, seed=5)
>>> output = C.poisson(shape, mean, seed=5)
"""
"""
mean_dtype
=
F
.
dtype
(
mean
)
const_utils
.
check_tensors_dtype_same
(
mean_dtype
,
mstype
.
float32
,
"poisson"
)
const_utils
.
check_non_negative
(
"seed"
,
seed
,
"poisson"
)
const_utils
.
check_non_negative
(
"seed"
,
seed
,
"poisson"
)
seed1
=
get_seed
()
seed1
=
get_seed
()
seed2
=
seed
seed2
=
seed
...
...
mindspore/ops/operations/random_ops.py
浏览文件 @
3259dafa
...
@@ -27,8 +27,8 @@ class StandardNormal(PrimitiveWithInfer):
...
@@ -27,8 +27,8 @@ class StandardNormal(PrimitiveWithInfer):
Generates random numbers according to the standard Normal (or Gaussian) random number distribution.
Generates random numbers according to the standard Normal (or Gaussian) random number distribution.
Args:
Args:
seed (int): Random seed. Default: 0.
seed (int): Random seed.
Must be non-negative.
Default: 0.
seed2 (int): Random seed2. Default: 0.
seed2 (int): Random seed2.
Must be non-negative.
Default: 0.
Inputs:
Inputs:
- **shape** (tuple) - The shape of random tensor to be generated. Only constant value is allowed.
- **shape** (tuple) - The shape of random tensor to be generated. Only constant value is allowed.
...
@@ -125,8 +125,8 @@ class Gamma(PrimitiveWithInfer):
...
@@ -125,8 +125,8 @@ class Gamma(PrimitiveWithInfer):
\text{P}(x|α,β) = \frac{\exp(-x/β)}{{β^α}\cdot{\Gamma(α)}}\cdot{x^{α-1}},
\text{P}(x|α,β) = \frac{\exp(-x/β)}{{β^α}\cdot{\Gamma(α)}}\cdot{x^{α-1}},
Args:
Args:
seed (int): Random seed. Default: 0.
seed (int): Random seed.
Must be non-negative.
Default: 0.
seed2 (int): Random seed2. Default: 0.
seed2 (int): Random seed2.
Must be non-negative.
Default: 0.
Inputs:
Inputs:
- **shape** (tuple) - The shape of random tensor to be generated. Only constant value is allowed.
- **shape** (tuple) - The shape of random tensor to be generated. Only constant value is allowed.
...
@@ -180,8 +180,8 @@ class Poisson(PrimitiveWithInfer):
...
@@ -180,8 +180,8 @@ class Poisson(PrimitiveWithInfer):
\text{P}(i|μ) = \frac{\exp(-μ)μ^{i}}{i!},
\text{P}(i|μ) = \frac{\exp(-μ)μ^{i}}{i!},
Args:
Args:
seed (int): Random seed. Default: 0.
seed (int): Random seed.
Must be non-negative.
Default: 0.
seed2 (int): Random seed2. Default: 0.
seed2 (int): Random seed2.
Must be non-negative.
Default: 0.
Inputs:
Inputs:
- **shape** (tuple) - The shape of random tensor to be generated. Only constant value is allowed.
- **shape** (tuple) - The shape of random tensor to be generated. Only constant value is allowed.
...
@@ -234,8 +234,8 @@ class UniformInt(PrimitiveWithInfer):
...
@@ -234,8 +234,8 @@ class UniformInt(PrimitiveWithInfer):
The number in tensor a should be strictly less than b at any position after broadcasting.
The number in tensor a should be strictly less than b at any position after broadcasting.
Args:
Args:
seed (int): Random seed. Default: 0.
seed (int): Random seed.
Must be non-negative.
Default: 0.
seed2 (int): Random seed2. Default: 0.
seed2 (int): Random seed2.
Must be non-negative.
Default: 0.
Inputs:
Inputs:
- **shape** (tuple) - The shape of random tensor to be generated. Only constant value is allowed.
- **shape** (tuple) - The shape of random tensor to be generated. Only constant value is allowed.
...
@@ -287,8 +287,8 @@ class UniformReal(PrimitiveWithInfer):
...
@@ -287,8 +287,8 @@ class UniformReal(PrimitiveWithInfer):
Produces random floating-point values i, uniformly distributed on the interval [0, 1).
Produces random floating-point values i, uniformly distributed on the interval [0, 1).
Args:
Args:
seed (int): Random seed. Default: 0.
seed (int): Random seed.
Must be non-negative.
Default: 0.
seed2 (int): Random seed2. Default: 0.
seed2 (int): Random seed2.
Must be non-negative.
Default: 0.
Inputs:
Inputs:
- **shape** (tuple) - The shape of random tensor to be generated. Only constant value is allowed.
- **shape** (tuple) - The shape of random tensor to be generated. Only constant value is allowed.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录