Browse Source

!97 Append parameter verification for 'attack_config'

Merge pull request !97 from liuluobin/master
tags/v1.2.1
mindspore-ci-bot Gitee 4 years ago
parent
commit
c789bf3142
1 changed files with 7 additions and 0 deletions
  1. +7
    -0
      mindarmour/diff_privacy/evaluation/membership_inference.py

+ 7
- 0
mindarmour/diff_privacy/evaluation/membership_inference.py View File

@@ -124,7 +124,14 @@ class MembershipInference:
raise TypeError("Type of parameter 'test_train' must be Dataset, "
"but got {}".format(type(dataset_train)))

if not isinstance(attack_config, list):
raise TypeError("Type of parameter 'attack_config' must be list, "
"but got {}.".format(type(attack_config)))

for config in attack_config:
if not isinstance(config, dict):
raise TypeError("Type of each config in 'attack_config' must be dict, "
"but got {}.".format(type(config)))
if {"params", "method"} != set(config.keys()):
raise KeyError("Each config in attack_config must have keys 'method' and 'params', "
"but your key value is {}.".format(set(config.keys())))


Loading…
Cancel
Save