GithubHelp home page GithubHelp logo

Comments (4)

wangaxe avatar wangaxe commented on August 24, 2024

不知道对不对,希望能帮到你

# pytorch版的model
def gradient(self, data, label):
         ...
         ...
        #loss=self._loss(output, label)
        ce = nn.CrossEntropyLoss()
        loss=-ce(output, label) #这里多了一个负号

from advbox.

ygfrancois avatar ygfrancois commented on August 24, 2024

不知道对不对,希望能帮到你

# pytorch版的model
def gradient(self, data, label):
         ...
         ...
        #loss=self._loss(output, label)
        ce = nn.CrossEntropyLoss()
        loss=-ce(output, label) #这里多了一个负号

谢谢回复,以下疑问:
nn.CrossEntropyLoss()里应该包含了negative log likelihood里的负号了对吧?那这里这个loss,加一个负号的意义在哪呢?难道仅仅为了不同子类调用时候的一致么?如果是这样,意味着其他model例如tf的model也多加了一个负号?不过我没有找到其他框架的model在哪里加了负号,能否指示一下,多谢了。

另贴上 cleverhans项目fast_gradient_method里target loss和非target loss的代码

  # Compute loss
  loss = softmax_cross_entropy_with_logits(labels=y, logits=logits)
  if targeted:
    loss = -loss

  # Define gradient of loss wrt input
  grad, = tf.gradients(loss, x)

  optimal_perturbation = optimize_linear(grad, eps, ord)

  # Add perturbation to original example to obtain adversarial example
  adv_x = x + optimal_perturbation

from advbox.

duoergun0729 avatar duoergun0729 commented on August 24, 2024

就是pytorch这个特殊点 其他的框架木有这个问题

from advbox.

txyugood avatar txyugood commented on August 24, 2024

我今天也遇到这个问题了,我觉得这块应该是bug,我看 log 里面以前is_targeted_attack是减号,但是在ef59511b59a03755c33e712043f9c2211829191b 这个 commit 里面改了,所以能否查一下这是是否有问题?

from advbox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.