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

!54 add a construct of clip_mech and noise_mech, when noise_mech is adaptive...

!54 add a construct of clip_mech and noise_mech, when noise_mech is adaptive clip_mech must be not none
Merge pull request !54 from ZhidanLiu/master
......@@ -143,7 +143,13 @@ class DPModel(Model):
LOGGER.error(TAG, msg)
raise ValueError(msg)
self._noise_mech = noise_mech
if clip_mech is not None:
if noise_mech is not None:
if 'Ada' in noise_mech.__class__.__name__ and clip_mech is not None:
msg = 'When noise_mech is Adaptive, clip_mech must be None.'
LOGGER.error(TAG, msg)
raise ValueError(msg)
if clip_mech is None or isinstance(clip_mech, Cell):
self._clip_mech = clip_mech
super(DPModel, self).__init__(**kwargs)
......
......@@ -134,11 +134,7 @@ def test_dp_model_with_graph_mode_ada_gaussian():
noise_mech = NoiseMechanismsFactory().create('AdaGaussian',
norm_bound=norm_clip,
initial_noise_multiplier=initial_noise_multiplier)
clip_mech = ClipMechanismsFactory().create('Gaussian',
decay_policy='Linear',
learning_rate=0.01,
target_unclipped_quantile=0.9,
fraction_stddev=0.01)
clip_mech = None
net_opt = nn.Momentum(network.trainable_params(), learning_rate=0.1,
momentum=0.9)
model = DPModel(micro_batches=2,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册