From dcc64ddde9c80b2cae7fdb0335ae8fedd8169194 Mon Sep 17 00:00:00 2001 From: liuluobin Date: Wed, 26 Aug 2020 14:34:23 +0800 Subject: [PATCH] Append parameter verification for 'attack_config' --- mindarmour/diff_privacy/evaluation/membership_inference.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mindarmour/diff_privacy/evaluation/membership_inference.py b/mindarmour/diff_privacy/evaluation/membership_inference.py index 4240f29..2841af3 100755 --- a/mindarmour/diff_privacy/evaluation/membership_inference.py +++ b/mindarmour/diff_privacy/evaluation/membership_inference.py @@ -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()))) -- GitLab