Merge pull request !263 from ZhidanLiu/mastertags/v1.6.0
@@ -51,7 +51,7 @@ def test_lenet_mnist_fuzzing(): | |||||
{'method': 'Shear', | {'method': 'Shear', | ||||
'params': {'auto_param': [True]}}, | 'params': {'auto_param': [True]}}, | ||||
{'method': 'FGSM', | {'method': 'FGSM', | ||||
'params': {'eps': [0.3, 0.2, 0.4], 'alpha': [0.1]}} | |||||
'params': {'eps': [0.3, 0.2, 0.4], 'alpha': [0.1], 'bounds': [(0, 1)]}} | |||||
] | ] | ||||
# get training data | # get training data | ||||
@@ -191,9 +191,9 @@ class Fuzzer: | |||||
- dict, metrics report of fuzzer. | - dict, metrics report of fuzzer. | ||||
Raises: | Raises: | ||||
ValueError, coverage must be subclass of CoverageMetrics. | |||||
ValueError, if initial seeds is empty. | |||||
ValueError, if element of seed is not two in initial seeds. | |||||
ValueError: Coverage must be subclass of CoverageMetrics. | |||||
ValueError: If initial seeds is empty. | |||||
ValueError: If element of seed is not two in initial seeds. | |||||
""" | """ | ||||
# Check parameters. | # Check parameters. | ||||
if not isinstance(coverage, CoverageMetrics): | if not isinstance(coverage, CoverageMetrics): | ||||
@@ -356,7 +356,7 @@ class Fuzzer: | |||||
check_param_type(param_name, params[param_name], list) | check_param_type(param_name, params[param_name], list) | ||||
for param_value in params[param_name]: | for param_value in params[param_name]: | ||||
if param_name == 'bounds': | if param_name == 'bounds': | ||||
_ = check_param_bounds('bounds', param_name) | |||||
_ = check_param_bounds('bounds', param_value) | |||||
elif param_name == 'norm_level': | elif param_name == 'norm_level': | ||||
_ = check_norm_level(param_value) | _ = check_norm_level(param_value) | ||||
else: | else: | ||||
@@ -157,8 +157,10 @@ class NeuronCoverage(CoverageMetrics): | |||||
""" | """ | ||||
def __init__(self, model, threshold=0.1, incremental=False, batch_size=32): | def __init__(self, model, threshold=0.1, incremental=False, batch_size=32): | ||||
super(NeuronCoverage, self).__init__(model, incremental, batch_size) | super(NeuronCoverage, self).__init__(model, incremental, batch_size) | ||||
threshold = check_param_type('threshold', threshold, float) | |||||
self.threshold = check_value_positive('threshold', threshold) | self.threshold = check_value_positive('threshold', threshold) | ||||
def get_metrics(self, dataset): | def get_metrics(self, dataset): | ||||
""" | """ | ||||
Get the metric of neuron coverage: the proportion of activated neurons to total neurons in the network. | Get the metric of neuron coverage: the proportion of activated neurons to total neurons in the network. | ||||