当前位置: 首页>>代码示例>>Python>>正文


Python attacks.MomentumIterativeMethod方法代码示例

本文整理汇总了Python中cleverhans.attacks.MomentumIterativeMethod方法的典型用法代码示例。如果您正苦于以下问题:Python attacks.MomentumIterativeMethod方法的具体用法?Python attacks.MomentumIterativeMethod怎么用?Python attacks.MomentumIterativeMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cleverhans.attacks的用法示例。


在下文中一共展示了attacks.MomentumIterativeMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_adv_examples

# 需要导入模块: from cleverhans import attacks [as 别名]
# 或者: from cleverhans.attacks import MomentumIterativeMethod [as 别名]
def create_adv_examples(model, input_t, x_to_adv, attack_dict):
    """
    This fn may seem bizarre and pointless, but the point of it is to
    enable the entire attack to be specified as a dict from the command line without
    editing this script, which is convenient for storing the settings used for an attack
    """
    if attack_dict['method'] == 'fgm':
        attack = attacks.FastGradientMethod(model, sess=K.get_session(), back='tf')
    elif attack_dict['method'] == 'bim':
        attack = attacks.BasicIterativeMethod(model, sess=K.get_session(), back='tf')
    elif attack_dict['method'] == 'mim':
        attack = attacks.MomentumIterativeMethod(model, sess=K.get_session(), back='tf')
    else:
        assert False, 'Current attack needs to be added to the create attack fn'
    adv_tensor = attack.generate(input_t, **{k: a for k, a in attack_dict.items() if
                                             k != 'method'})  # 'method' key for this fn use
    x_adv = batch_eval(adv_tensor, input_t, x_to_adv, batch_size=args.batch_size, verbose="Generating adv examples")
    return x_adv 
开发者ID:lsgos,项目名称:uncertainty-adversarial-paper,代码行数:20,代码来源:ROC_curves_cats.py

示例2: setUp

# 需要导入模块: from cleverhans import attacks [as 别名]
# 或者: from cleverhans.attacks import MomentumIterativeMethod [as 别名]
def setUp(self):
        super(TestMomentumIterativeMethod, self).setUp()

        self.sess = tf.Session()
        self.model = SimpleModel()
        self.attack = MomentumIterativeMethod(self.model, sess=self.sess) 
开发者ID:StephanZheng,项目名称:neural-fingerprinting,代码行数:8,代码来源:test_attacks.py

示例3: setUp

# 需要导入模块: from cleverhans import attacks [as 别名]
# 或者: from cleverhans.attacks import MomentumIterativeMethod [as 别名]
def setUp(self):
    super(TestMomentumIterativeMethod, self).setUp()

    self.attack = MomentumIterativeMethod(self.model, sess=self.sess) 
开发者ID:tensorflow,项目名称:cleverhans,代码行数:6,代码来源:test_attacks.py


注:本文中的cleverhans.attacks.MomentumIterativeMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。