提交 f85860b3 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!27 Solve DI: [MA][diff_privacy][Func]GaussianRandom return Tensor but api...

!27 Solve DI: [MA][diff_privacy][Func]GaussianRandom return Tensor but api show return np.ndarray  https://gitee.com/mindspore/dashboard/issues?id=I1ILXP
Merge pull request !27 from ZhidanLiu/master
...@@ -106,7 +106,7 @@ class GaussianRandom(Mechanisms): ...@@ -106,7 +106,7 @@ class GaussianRandom(Mechanisms):
shape(tuple): The shape of gradients. shape(tuple): The shape of gradients.
Returns: Returns:
numpy.ndarray, generated noise. Tensor, generated noise.
""" """
shape = check_param_type('shape', shape, tuple) shape = check_param_type('shape', shape, tuple)
noise = np.random.normal(self._mean, self._stddev, shape) noise = np.random.normal(self._mean, self._stddev, shape)
...@@ -136,7 +136,7 @@ class AdaGaussianRandom(Mechanisms): ...@@ -136,7 +136,7 @@ class AdaGaussianRandom(Mechanisms):
>>> norm_bound = 1.0 >>> norm_bound = 1.0
>>> initial_noise_multiplier = 0.1 >>> initial_noise_multiplier = 0.1
>>> alpha = 0.5 >>> alpha = 0.5
>>> decay_policy = "Step" >>> decay_policy = "Time"
>>> net = AdaGaussianRandom(norm_bound, initial_noise_multiplier, >>> net = AdaGaussianRandom(norm_bound, initial_noise_multiplier,
>>> alpha, decay_policy) >>> alpha, decay_policy)
>>> res = net(shape) >>> res = net(shape)
...@@ -144,7 +144,7 @@ class AdaGaussianRandom(Mechanisms): ...@@ -144,7 +144,7 @@ class AdaGaussianRandom(Mechanisms):
""" """
def __init__(self, norm_bound=1.5, initial_noise_multiplier=5.0, def __init__(self, norm_bound=1.5, initial_noise_multiplier=5.0,
alpha=6e-4, decay_policy='Step'): alpha=6e-4, decay_policy='Time'):
super(AdaGaussianRandom, self).__init__() super(AdaGaussianRandom, self).__init__()
initial_noise_multiplier = check_value_positive('initial_noise_multiplier', initial_noise_multiplier = check_value_positive('initial_noise_multiplier',
initial_noise_multiplier) initial_noise_multiplier)
...@@ -194,7 +194,7 @@ class AdaGaussianRandom(Mechanisms): ...@@ -194,7 +194,7 @@ class AdaGaussianRandom(Mechanisms):
shape(tuple): The shape of gradients. shape(tuple): The shape of gradients.
Returns: Returns:
numpy.ndarray, generated noise. Tensor, generated noise.
""" """
shape = check_param_type('shape', shape, tuple) shape = check_param_type('shape', shape, tuple)
noise = np.random.normal(self._mean, self._stddev.asnumpy(), noise = np.random.normal(self._mean, self._stddev.asnumpy(),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册