Code Monkey home page Code Monkey logo

Comments (4)

SanghyukChun avatar SanghyukChun commented on July 28, 2024

Thanks for the question.
We propose to mix the two targets not using a single target in the paper. As you can see (1) and Appendix A1.

Equation (1)

Appendix A1

Here, each "y" is a one-hot label (thus an example of \hat y is [0.6, 0.4, 0, 0, 0])
Note that computing the cross-entropy between the mixed target and the prediction is equivalent to mix two cross entropies with a single target, i.e.,

CE(mixed_label_between_ya_yb, prediction) = lambda * CE(ya, prediction) + (1 - lambda) CE(yb, prediction)

The above equation is easily derived from the definition of the cross entropy.
There is no change after we made the first version of the CutMix algorithm, and our code is consistent with our paper.
Thanks

from cutmix-pytorch.

shim94kr avatar shim94kr commented on July 28, 2024

I'm greatly appreciated for your prompt response!

I didn't notice the equivalence be satisfied before!

But still wondering, is there a particular issue on implementing with CE(mixed_label_between_ya_yb, prediction)? Why did you implement with the equivalent form, not the original one? At first glance, the original formula is also equally easy to implement.

Thank you!

from cutmix-pytorch.

SanghyukChun avatar SanghyukChun commented on July 28, 2024

@shim94kr
Technically speaking, the CE in my comment and CE in PyTorch is not equivalent.
The cross entropy implementation of PyTorch, and most ML frameworks, gets "index" not the probability itself. I.e., "target" is not a one-hot (e.g., [1, 0, 0, 0, ...]) but index value (e.g., 34) for PyTorch CE.
Since the cross entropy implementation is highly optimized ("This criterion combines LogSoftmax and NLLLoss in one single class" from the document), we do not create our own CE implementation.
See the official document for the details.

from cutmix-pytorch.

shim94kr avatar shim94kr commented on July 28, 2024

I'm now clear on this issue. Thank you!

from cutmix-pytorch.

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.