fra31 / auto-attack

Code relative to "Reliable evaluation of adversarial robustness with an ensemble of diverse parameter-free attacks"
https://arxiv.org/abs/2003.01690
MIT License
639 stars 111 forks source link

Unable to use in TF2 #89

Open Shubhajit1988 opened 2 years ago

Shubhajit1988 commented 2 years ago

Dear sir, When I call 'adversary.run_standard_evaluation', it shows 'ModelAdapter' object is not callable

fra31 commented 2 years ago

Hi,

it's a bit hard to say with little context, but I guess it might be because the flag is_tf_model=True is not set (see here).

isaacwasserman commented 2 years ago

I can confirm this behavior. In each of the attacks, model(x) is called. I believe this should be model.predict(x) instead.

fra31 commented 2 years ago

Hi,

could you please point to the exact points where this happens? I think there should always be an if statement to distinguish whether the model is a TF one and then call model.predict.

isaacwasserman commented 2 years ago

It happens in checks.py:

def check_dynamic(model, x, is_tf_model=False, logger=None):
    if is_tf_model:
        msg = 'the check for dynamic defenses is not currently supported'
    else:
        msg = None
    sys.settrace(tracefunc)
    model(x)
    sys.settrace(None)
    #for k, v in funcs.items():
    #    print(k, v)
    if any([c > 0 for c in funcs.values()]):
        msg = 'it seems to be a dynamic defense! The evaluation' + \
            ' with AutoAttack might be insufficient.' + \
            f' See {checks_doc_path} for details.'
    if not msg is None:
        if logger is None:
            warnings.warn(Warning(msg))
        else:
            logger.log(f'Warning: {msg}')
    #sys.settrace(None)
fra31 commented 2 years ago

Sorry for the late reply. This https://github.com/fra31/auto-attack/pull/92 should fix it.