From b863324d904a3e052e83f9c41e43ff53cfeb3c25 Mon Sep 17 00:00:00 2001 From: Yi Huaijie Date: Mon, 21 Sep 2020 10:26:05 +0800 Subject: [PATCH] move set_seed() out from construct() of Net --- tests/st/ops/ascend/test_compoite_random_ops/test_gamma.py | 3 +-- tests/st/ops/ascend/test_compoite_random_ops/test_normal.py | 3 +-- tests/st/ops/ascend/test_compoite_random_ops/test_poisson.py | 3 +-- tests/st/ops/ascend/test_compoite_random_ops/test_uniform.py | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/st/ops/ascend/test_compoite_random_ops/test_gamma.py b/tests/st/ops/ascend/test_compoite_random_ops/test_gamma.py index 96c8ce3a6c..623df2771c 100644 --- a/tests/st/ops/ascend/test_compoite_random_ops/test_gamma.py +++ b/tests/st/ops/ascend/test_compoite_random_ops/test_gamma.py @@ -22,7 +22,7 @@ from mindspore.ops import composite as C from mindspore.common import set_seed context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") - +set_seed(20) class Net(nn.Cell): def __init__(self, shape, seed=0): @@ -31,7 +31,6 @@ class Net(nn.Cell): self.seed = seed def construct(self, alpha, beta): - set_seed(20) return C.gamma(self.shape, alpha, beta, self.seed) diff --git a/tests/st/ops/ascend/test_compoite_random_ops/test_normal.py b/tests/st/ops/ascend/test_compoite_random_ops/test_normal.py index 10cca4768d..b9b7d2a84a 100644 --- a/tests/st/ops/ascend/test_compoite_random_ops/test_normal.py +++ b/tests/st/ops/ascend/test_compoite_random_ops/test_normal.py @@ -22,7 +22,7 @@ from mindspore.ops import composite as C from mindspore.common import set_seed context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") - +set_seed(20) class Net(nn.Cell): def __init__(self, shape, seed=0): @@ -31,7 +31,6 @@ class Net(nn.Cell): self.seed = seed def construct(self, mean, stddev): - set_seed(20) return C.normal(self.shape, mean, stddev, self.seed) diff --git a/tests/st/ops/ascend/test_compoite_random_ops/test_poisson.py b/tests/st/ops/ascend/test_compoite_random_ops/test_poisson.py index df1e1f49ef..fd6d521592 100644 --- a/tests/st/ops/ascend/test_compoite_random_ops/test_poisson.py +++ b/tests/st/ops/ascend/test_compoite_random_ops/test_poisson.py @@ -22,7 +22,7 @@ from mindspore.ops import composite as C from mindspore.common import set_seed context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") - +set_seed(20) class Net(nn.Cell): def __init__(self, shape, seed=0): @@ -31,7 +31,6 @@ class Net(nn.Cell): self.seed = seed def construct(self, mean): - set_seed(20) return C.poisson(self.shape, mean, self.seed) diff --git a/tests/st/ops/ascend/test_compoite_random_ops/test_uniform.py b/tests/st/ops/ascend/test_compoite_random_ops/test_uniform.py index f2f72e0cee..d671c46fc9 100644 --- a/tests/st/ops/ascend/test_compoite_random_ops/test_uniform.py +++ b/tests/st/ops/ascend/test_compoite_random_ops/test_uniform.py @@ -22,7 +22,7 @@ from mindspore.ops import composite as C from mindspore.common import set_seed context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") - +set_seed(20) class Net(nn.Cell): def __init__(self, shape, seed=0): @@ -31,7 +31,6 @@ class Net(nn.Cell): self.seed = seed def construct(self, minval, maxval): - set_seed(20) return C.uniform(self.shape, minval, maxval, self.seed)