Browse Source

!96 keep the type of parameters in fuzzing consistent with that in the called methods

Merge pull request !96 from ZhidanLiu/master
tags/v1.2.1
mindspore-ci-bot Gitee 4 years ago
parent
commit
b69a303257
2 changed files with 19 additions and 15 deletions
  1. +11
    -11
      mindarmour/fuzzing/fuzzing.py
  2. +8
    -4
      mindarmour/fuzzing/image_transform.py

+ 11
- 11
mindarmour/fuzzing/fuzzing.py View File

@@ -117,21 +117,21 @@ class Fuzzer:
'Noise']
self._attacks_list = ['FGSM', 'PGD', 'MDIIM']
self._attack_param_checklists = {
'FGSM': {'params': {'eps': {'dtype': [float, int], 'range': [0, 1]},
'alpha': {'dtype': [float, int],
'FGSM': {'params': {'eps': {'dtype': [float], 'range': [0, 1]},
'alpha': {'dtype': [float],
'range': [0, 1]},
'bounds': {'dtype': [list, tuple]}}},
'PGD': {'params': {'eps': {'dtype': [float, int], 'range': [0, 1]},
'eps_iter': {'dtype': [float, int],
'range': [0, 1e5]},
'nb_iter': {'dtype': [float, int],
'bounds': {'dtype': [tuple]}}},
'PGD': {'params': {'eps': {'dtype': [float], 'range': [0, 1]},
'eps_iter': {'dtype': [float],
'range': [0, 1]},
'nb_iter': {'dtype': [int],
'range': [0, 1e5]},
'bounds': {'dtype': [list, tuple]}}},
'bounds': {'dtype': [tuple]}}},
'MDIIM': {
'params': {'eps': {'dtype': [float, int], 'range': [0, 1]},
'params': {'eps': {'dtype': [float], 'range': [0, 1]},
'norm_level': {'dtype': [str]},
'prob': {'dtype': [float, int], 'range': [0, 1]},
'bounds': {'dtype': [list, tuple]}}}}
'prob': {'dtype': [float], 'range': [0, 1]},
'bounds': {'dtype': [tuple]}}}}

def fuzzing(self, mutate_config, initial_seeds, coverage_metric='KMNC',
eval_metrics='auto', max_iters=10000, mutate_num_per_seed=20):


+ 8
- 4
mindarmour/fuzzing/image_transform.py View File

@@ -350,8 +350,10 @@ class Translate(ImageTransform):
Translate an image.

Args:
x_bias ([int, float): X-direction translation, x=x+x_bias. Default: 0.
y_bias ([int, float): Y-direction translation, y=y+y_bias. Default: 0.
x_bias ([int, float): X-direction translation, x=x+x_bias*image_length.
Default: 0.
y_bias ([int, float): Y-direction translation, y=y+y_bias*image_wide.
Default: 0.
"""

def __init__(self, x_bias=0, y_bias=0):
@@ -363,8 +365,10 @@ class Translate(ImageTransform):
Set translate parameters.

Args:
x_bias ([float, int]): X-direction translation, x=x+x_bias. Default: 0.
y_bias ([float, int]): Y-direction translation, y=y+y_bias. Default: 0.
x_bias ([float, int]): X-direction translation, x=x+x_bias*image_length.
Default: 0.
y_bias ([float, int]): Y-direction translation, y=y+y_bias*image_wide.
Default: 0.
auto_param (bool): True if auto generate parameters. Default: False.
"""
self.auto_param = auto_param


Loading…
Cancel
Save