!6618 move set_seed() out from construct() of Net

Merge pull request !6618 from yihuaijie/seed
This commit is contained in:
mindspore-ci-bot 2020-09-21 14:15:48 +08:00 committed by Gitee
commit 0c6f1a663c
4 changed files with 4 additions and 8 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)