提交 8113cb24 编写于 作者: Z ZhidanLiu

fix a bug in evaluate of fuzzing

上级 f9328348
...@@ -393,13 +393,19 @@ class Fuzzer: ...@@ -393,13 +393,19 @@ class Fuzzer:
temp = np.argmax(gt_labels, axis=1) == np.argmax(fuzz_preds, axis=1) temp = np.argmax(gt_labels, axis=1) == np.argmax(fuzz_preds, axis=1)
metrics_report = {} metrics_report = {}
if metrics == 'auto' or 'accuracy' in metrics: if metrics == 'auto' or 'accuracy' in metrics:
if temp.any():
acc = np.sum(temp) / np.size(temp) acc = np.sum(temp) / np.size(temp)
else:
acc = 0
metrics_report['Accuracy'] = acc metrics_report['Accuracy'] = acc
if metrics == 'auto' or 'attack_success_rate' in metrics: if metrics == 'auto' or 'attack_success_rate' in metrics:
cond = [elem in self._attacks_list for elem in fuzz_strategies] cond = [elem in self._attacks_list for elem in fuzz_strategies]
temp = temp[cond] temp = temp[cond]
if temp.any():
attack_success_rate = 1 - np.sum(temp) / np.size(temp) attack_success_rate = 1 - np.sum(temp) / np.size(temp)
else:
attack_success_rate = None
metrics_report['Attack_success_rate'] = attack_success_rate metrics_report['Attack_success_rate'] = attack_success_rate
if metrics == 'auto' or 'kmnc' in metrics or 'nbc' in metrics or 'snac' in metrics: if metrics == 'auto' or 'kmnc' in metrics or 'nbc' in metrics or 'snac' in metrics:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册