ResNet/main.py
def create_eval_callback(name, tower_func, condition):
    """
    Create a distributed evaluation callback.

    Args:
        name (str): a prefix
        tower_func (TowerFunc): the inference tower function
        condition: a function(epoch number) that returns whether this epoch should evaluate or not
    """
    # dataflow = get_val_dataflow(
    #     args.data, args.batch,
    #     num_splits=hvd.size(), split_index=hvd.rank())
    dataflow = get_val_dataflow(args.data, args.batch)
    # We eval both the classification error rate (for comparison with defenders)
    # and the attack success rate (for comparison with attackers).
    infs = [ClassificationError('wrong-top1', '{}-top1-error'.format(name)),
            ClassificationError('wrong-top5', '{}-top5-error'.format(name)),
            # ClassificationError('attack_success', '{}-attack-success-rate'.format(name))
            ]
    cb = InferenceRunner(
        QueueInput(dataflow), infs,
        tower_name=name,
        tower_func=tower_func).set_chief_only(False)
    cb = EnableCallbackIf(
        cb, lambda self: condition(self.epoch_num))
    return cb

    Create a distributed evaluation callback.

    Args:
        name (str): a prefix
        tower_func (TowerFunc): the inference tower function
        condition: a function(epoch number) that returns whether this epoch should evaluate or not
    
Create a distributed evaluation callback.
Create a distributed evaluation callback .
def create_eval_callback(name, tower_func, condition):
    dataflow = get_val_dataflow(args.data, args.batch)
    infs = [ClassificationError('wrong-top1', '{}-top1-error'.format(name)),
            ClassificationError('wrong-top5', '{}-top5-error'.format(name)),
            ]
    cb = InferenceRunner(
        QueueInput(dataflow), infs,
        tower_name=name,
        tower_func=tower_func).set_chief_only(False)
    cb = EnableCallbackIf(
        cb, lambda self: condition(self.epoch_num))
    return cb
def create_eval_callback ( name , tower_func , condition ) : dataflow = get_val_dataflow ( args . data , args . batch ) infs = [ ClassificationError ( 'wrong-top1' , '{}-top1-error' . format ( name ) ) , ClassificationError ( 'wrong-top5' , '{}-top5-error' . format ( name ) ) , ] cb = InferenceRunner ( QueueInput ( dataflow ) , infs , tower_name = name , tower_func = tower_func ) . set_chief_only ( False ) cb = EnableCallbackIf ( cb , lambda self : condition ( self . epoch_num ) ) return cb
Create a distributed evaluation callback.
Create a distributed evaluation callback .
"""
    Create a distributed evaluation callback.

    Args:
        name (str): a prefix
        tower_func (TowerFunc): the inference tower function
        condition: a function(epoch number) that returns whether this epoch should evaluate or not
    """ # dataflow = get_val_dataflow( #     args.data, args.batch, #     num_splits=hvd.size(), split_index=hvd.rank()) # We eval both the classification error rate (for comparison with defenders) # and the attack success rate (for comparison with attackers). # ClassificationError('attack_success', '{}-attack-success-rate'.format(name))
name
None
tower_func
the inference tower function
the inference tower function
condition
a function(epoch number) that returns whether this epoch should evaluate or not
a function ( epoch number ) that returns whether this epoch should evaluate or not