Browse Source

!212 Fix an issue of inversion_attack

From: @jxlang910
Reviewed-by: @liu_luobin,@zhidanliu,@pkuliuliu
Signed-off-by: @pkuliuliu
tags/v1.3.0
mindspore-ci-bot Gitee 4 years ago
parent
commit
9a5af8b252
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      mindarmour/privacy/evaluation/inversion_attack.py

+ 2
- 2
mindarmour/privacy/evaluation/inversion_attack.py View File

@@ -65,7 +65,7 @@ class InversionLoss(Cell):
Tensor, inversion attack loss of the current iteration.
"""
output = self._network(input_data)
loss_1 = self._mse_loss(output, target_features) / self._mse_loss(target_features, 0)
loss_1 = self._mse_loss(output, target_features) / self._mse_loss(target_features, self._zeros(target_features))

data_shape = self._get_shape(input_data)
if self._device_target == 'CPU':
@@ -85,7 +85,7 @@ class InversionLoss(Cell):
data_copy_2[:, :, :, :(data_shape[2] - 1)] = input_data[:, :, :, 1:]
loss_2 = self._mse_loss(input_data, data_copy_1) + self._mse_loss(input_data, data_copy_2)

loss_3 = self._mse_loss(input_data, 0)
loss_3 = self._mse_loss(input_data, self._zeros(input_data))

loss = loss_1*self._weights[0] + loss_2*self._weights[1] + loss_3*self._weights[2]
return loss


Loading…
Cancel
Save