Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
d8a9ba56
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
d8a9ba56
编写于
1月 18, 2021
作者:
L
lijianshe02
提交者:
GitHub
1月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix random seed in nll_loss unittest test=develop (#30468)
上级
5d8d463c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
0 deletion
+22
-0
python/paddle/fluid/tests/unittests/test_nll_loss.py
python/paddle/fluid/tests/unittests/test_nll_loss.py
+22
-0
未找到文件。
python/paddle/fluid/tests/unittests/test_nll_loss.py
浏览文件 @
d8a9ba56
...
@@ -74,6 +74,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -74,6 +74,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_1D_mean
(
self
):
def
test_NLLLoss_1D_mean
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
10
,
10
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
10
,
10
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
10
,
size
=
(
10
,
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
10
,
size
=
(
10
,
)).
astype
(
np
.
int64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
startup_prog
=
fluid
.
Program
()
startup_prog
=
fluid
.
Program
()
...
@@ -108,6 +109,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -108,6 +109,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_1D_sum
(
self
):
def
test_NLLLoss_1D_sum
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
10
,
10
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
10
,
10
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
10
,
size
=
(
10
,
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
10
,
size
=
(
10
,
)).
astype
(
np
.
int64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
startup_prog
=
fluid
.
Program
()
startup_prog
=
fluid
.
Program
()
...
@@ -142,6 +144,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -142,6 +144,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_1D_with_weight_mean
(
self
):
def
test_NLLLoss_1D_with_weight_mean
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
10
,
10
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
10
,
10
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
10
,
size
=
(
10
,
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
10
,
size
=
(
10
,
)).
astype
(
np
.
int64
)
weight_np
=
np
.
random
.
random
(
size
=
(
10
,
)).
astype
(
np
.
float64
)
weight_np
=
np
.
random
.
random
(
size
=
(
10
,
)).
astype
(
np
.
float64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
...
@@ -181,6 +184,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -181,6 +184,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_1D_with_weight_sum
(
self
):
def
test_NLLLoss_1D_with_weight_sum
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
10
,
10
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
10
,
10
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
10
,
size
=
(
10
,
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
10
,
size
=
(
10
,
)).
astype
(
np
.
int64
)
weight_np
=
np
.
random
.
random
(
size
=
(
10
,
)).
astype
(
np
.
float64
)
weight_np
=
np
.
random
.
random
(
size
=
(
10
,
)).
astype
(
np
.
float64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
...
@@ -221,6 +225,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -221,6 +225,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_1D_with_weight_mean_cpu
(
self
):
def
test_NLLLoss_1D_with_weight_mean_cpu
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
10
,
10
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
10
,
10
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
10
,
size
=
(
10
,
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
10
,
size
=
(
10
,
)).
astype
(
np
.
int64
)
weight_np
=
np
.
random
.
random
(
size
=
(
10
,
)).
astype
(
np
.
float64
)
weight_np
=
np
.
random
.
random
(
size
=
(
10
,
)).
astype
(
np
.
float64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
...
@@ -258,6 +263,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -258,6 +263,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_1D_with_weight_no_reduce_cpu
(
self
):
def
test_NLLLoss_1D_with_weight_no_reduce_cpu
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
10
,
10
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
10
,
10
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
10
,
size
=
(
10
,
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
10
,
size
=
(
10
,
)).
astype
(
np
.
int64
)
weight_np
=
np
.
random
.
random
(
size
=
(
10
,
)).
astype
(
np
.
float64
)
weight_np
=
np
.
random
.
random
(
size
=
(
10
,
)).
astype
(
np
.
float64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
...
@@ -296,6 +302,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -296,6 +302,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_2D_mean
(
self
):
def
test_NLLLoss_2D_mean
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
)).
astype
(
np
.
int64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
startup_prog
=
fluid
.
Program
()
startup_prog
=
fluid
.
Program
()
...
@@ -332,6 +339,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -332,6 +339,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_2D_sum
(
self
):
def
test_NLLLoss_2D_sum
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
)).
astype
(
np
.
int64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
startup_prog
=
fluid
.
Program
()
startup_prog
=
fluid
.
Program
()
...
@@ -368,6 +376,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -368,6 +376,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_2D_with_weight_mean
(
self
):
def
test_NLLLoss_2D_with_weight_mean
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
)).
astype
(
np
.
int64
)
weight_np
=
np
.
random
.
random
(
size
=
(
3
,
)).
astype
(
np
.
float64
)
weight_np
=
np
.
random
.
random
(
size
=
(
3
,
)).
astype
(
np
.
float64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
...
@@ -410,6 +419,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -410,6 +419,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_2D_with_weight_mean_cpu
(
self
):
def
test_NLLLoss_2D_with_weight_mean_cpu
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
)).
astype
(
np
.
int64
)
weight_np
=
np
.
random
.
random
(
size
=
(
3
,
)).
astype
(
np
.
float64
)
weight_np
=
np
.
random
.
random
(
size
=
(
3
,
)).
astype
(
np
.
float64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
...
@@ -450,6 +460,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -450,6 +460,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_2D_with_weight_sum
(
self
):
def
test_NLLLoss_2D_with_weight_sum
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
)).
astype
(
np
.
int64
)
weight_np
=
np
.
random
.
random
(
size
=
(
3
,
)).
astype
(
np
.
float64
)
weight_np
=
np
.
random
.
random
(
size
=
(
3
,
)).
astype
(
np
.
float64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
...
@@ -492,6 +503,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -492,6 +503,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_in_dims_not_2or4_mean
(
self
):
def
test_NLLLoss_in_dims_not_2or4_mean
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
,
5
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
,
5
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
,
5
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
,
5
)).
astype
(
np
.
int64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
startup_prog
=
fluid
.
Program
()
startup_prog
=
fluid
.
Program
()
...
@@ -533,6 +545,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -533,6 +545,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_in_dims_not_2or4_with_weight_mean
(
self
):
def
test_NLLLoss_in_dims_not_2or4_with_weight_mean
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
,
5
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
,
5
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
,
5
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
,
5
)).
astype
(
np
.
int64
)
weight_np
=
np
.
random
.
random
(
size
=
(
3
,
)).
astype
(
np
.
float64
)
weight_np
=
np
.
random
.
random
(
size
=
(
3
,
)).
astype
(
np
.
float64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
...
@@ -580,6 +593,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -580,6 +593,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_in_dims_not_2or4_with_weight_sum
(
self
):
def
test_NLLLoss_in_dims_not_2or4_with_weight_sum
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
,
5
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
,
5
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
,
5
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
,
5
)).
astype
(
np
.
int64
)
weight_np
=
np
.
random
.
random
(
size
=
(
3
,
)).
astype
(
np
.
float64
)
weight_np
=
np
.
random
.
random
(
size
=
(
3
,
)).
astype
(
np
.
float64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
...
@@ -630,6 +644,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -630,6 +644,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_in_dims_not_2or4_with_weight_no_reduce
(
self
):
def
test_NLLLoss_in_dims_not_2or4_with_weight_no_reduce
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
,
5
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
,
5
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
,
5
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
,
5
)).
astype
(
np
.
int64
)
weight_np
=
np
.
random
.
random
(
size
=
(
3
,
)).
astype
(
np
.
float64
)
weight_np
=
np
.
random
.
random
(
size
=
(
3
,
)).
astype
(
np
.
float64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
...
@@ -681,6 +696,7 @@ class TestNLLLoss(unittest.TestCase):
...
@@ -681,6 +696,7 @@ class TestNLLLoss(unittest.TestCase):
def
test_NLLLoss_in_dims_not_2or4_with_weight_no_reduce_cpu
(
self
):
def
test_NLLLoss_in_dims_not_2or4_with_weight_no_reduce_cpu
(
self
):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
,
5
)).
astype
(
np
.
float64
)
input_np
=
np
.
random
.
random
(
size
=
(
5
,
3
,
5
,
5
,
5
)).
astype
(
np
.
float64
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
,
5
)).
astype
(
np
.
int64
)
label_np
=
np
.
random
.
randint
(
0
,
3
,
size
=
(
5
,
5
,
5
,
5
)).
astype
(
np
.
int64
)
weight_np
=
np
.
random
.
random
(
size
=
(
3
,
)).
astype
(
np
.
float64
)
weight_np
=
np
.
random
.
random
(
size
=
(
3
,
)).
astype
(
np
.
float64
)
prog
=
fluid
.
Program
()
prog
=
fluid
.
Program
()
...
@@ -736,11 +752,13 @@ class TestNLLLossOp1DWithReduce(OpTest):
...
@@ -736,11 +752,13 @@ class TestNLLLossOp1DWithReduce(OpTest):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
uniform
(
0.1
,
0.8
,
input_np
=
np
.
random
.
uniform
(
0.1
,
0.8
,
self
.
input_shape
).
astype
(
"float64"
)
self
.
input_shape
).
astype
(
"float64"
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
self
.
input_shape
[
1
],
label_np
=
np
.
random
.
randint
(
0
,
self
.
input_shape
[
1
],
self
.
label_shape
).
astype
(
"int64"
)
self
.
label_shape
).
astype
(
"int64"
)
output_np
,
total_weight_np
=
nll_loss_1d
(
input_np
,
label_np
)
output_np
,
total_weight_np
=
nll_loss_1d
(
input_np
,
label_np
)
self
.
inputs
=
{
'X'
:
input_np
,
'Label'
:
label_np
}
self
.
inputs
=
{
'X'
:
input_np
,
'Label'
:
label_np
}
if
self
.
with_weight
:
if
self
.
with_weight
:
np
.
random
.
seed
(
200
)
weight_np
=
np
.
random
.
uniform
(
0.1
,
0.8
,
weight_np
=
np
.
random
.
uniform
(
0.1
,
0.8
,
self
.
input_shape
[
1
]).
astype
(
"float64"
)
self
.
input_shape
[
1
]).
astype
(
"float64"
)
output_np
,
total_weight_np
=
nll_loss_1d
(
output_np
,
total_weight_np
=
nll_loss_1d
(
...
@@ -778,12 +796,14 @@ class TestNLLLossOp1DNoReduce(OpTest):
...
@@ -778,12 +796,14 @@ class TestNLLLossOp1DNoReduce(OpTest):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
uniform
(
0.1
,
0.8
,
input_np
=
np
.
random
.
uniform
(
0.1
,
0.8
,
self
.
input_shape
).
astype
(
"float64"
)
self
.
input_shape
).
astype
(
"float64"
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
self
.
input_shape
[
1
],
label_np
=
np
.
random
.
randint
(
0
,
self
.
input_shape
[
1
],
self
.
label_shape
).
astype
(
"int64"
)
self
.
label_shape
).
astype
(
"int64"
)
output_np
=
nll_loss_1d
(
input_np
,
label_np
,
reduction
=
'none'
)
output_np
=
nll_loss_1d
(
input_np
,
label_np
,
reduction
=
'none'
)
total_weight_np
=
np
.
array
([
0
]).
astype
(
'float64'
)
total_weight_np
=
np
.
array
([
0
]).
astype
(
'float64'
)
self
.
inputs
=
{
'X'
:
input_np
,
'Label'
:
label_np
}
self
.
inputs
=
{
'X'
:
input_np
,
'Label'
:
label_np
}
if
self
.
with_weight
:
if
self
.
with_weight
:
np
.
random
.
seed
(
200
)
weight_np
=
np
.
random
.
uniform
(
0.1
,
0.8
,
weight_np
=
np
.
random
.
uniform
(
0.1
,
0.8
,
self
.
input_shape
[
1
]).
astype
(
"float64"
)
self
.
input_shape
[
1
]).
astype
(
"float64"
)
output_np
,
total_weight_np
=
nll_loss_1d
(
output_np
,
total_weight_np
=
nll_loss_1d
(
...
@@ -865,12 +885,14 @@ class TestNLLLossOp2DNoReduce(OpTest):
...
@@ -865,12 +885,14 @@ class TestNLLLossOp2DNoReduce(OpTest):
np
.
random
.
seed
(
200
)
np
.
random
.
seed
(
200
)
input_np
=
np
.
random
.
uniform
(
0.1
,
0.8
,
input_np
=
np
.
random
.
uniform
(
0.1
,
0.8
,
self
.
input_shape
).
astype
(
"float64"
)
self
.
input_shape
).
astype
(
"float64"
)
np
.
random
.
seed
(
200
)
label_np
=
np
.
random
.
randint
(
0
,
self
.
input_shape
[
1
],
label_np
=
np
.
random
.
randint
(
0
,
self
.
input_shape
[
1
],
self
.
label_shape
).
astype
(
"int64"
)
self
.
label_shape
).
astype
(
"int64"
)
output_np
=
nll_loss_2d
(
input_np
,
label_np
,
reduction
=
'none'
)
output_np
=
nll_loss_2d
(
input_np
,
label_np
,
reduction
=
'none'
)
total_weight_np
=
np
.
array
([
0
]).
astype
(
'float64'
)
total_weight_np
=
np
.
array
([
0
]).
astype
(
'float64'
)
self
.
inputs
=
{
'X'
:
input_np
,
'Label'
:
label_np
}
self
.
inputs
=
{
'X'
:
input_np
,
'Label'
:
label_np
}
if
self
.
with_weight
:
if
self
.
with_weight
:
np
.
random
.
seed
(
200
)
weight_np
=
np
.
random
.
uniform
(
0.1
,
0.8
,
weight_np
=
np
.
random
.
uniform
(
0.1
,
0.8
,
self
.
input_shape
[
1
]).
astype
(
"float64"
)
self
.
input_shape
[
1
]).
astype
(
"float64"
)
output_np
,
total_weight_np
=
nll_loss_2d
(
output_np
,
total_weight_np
=
nll_loss_2d
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录