Giter VIP home page Giter VIP logo

tf_multiclass's Introduction

TF Multiclass

Multiclass hinge losses for TensorFlow.

Tested with TensorFlow 2.4.1 and 2.5.0.

This package implements the following losses in the permutation-equivariant relative-margin (PERM) loss framework (more on this at the very end):

  1. Weston-Watkins hinge. Reference.
  2. Crammer-Singer hinge. Reference.
  3. Duchi-Ruan-Khosravi hinge. Referred to as the family-wise loss and the adversarial zero-one loss.
  4. Cross entropy.

How to use

There are examples in the jupyter_notebooks directory.

The notebook 02_linear_WWSVM_in_TensorFlow.ipynb shows how to use TensorFlow to train linear multiclass SVMs.

The notebook 03_comparing_cross_entropy_implementations.ipynb compares our implementation of the cross entropy with the standard TensorFlow's implementation. (They are probably the same).

FAQ

Fictitiously asked questions, since this repository may still be unknown.

Is this cross entropy the same as THE cross entropy?

By THE cross entropy, I am referring to tf.keras.losses.CategoricalCrossentropy(from_logits=True). This is based on absolute margins. I will call this the absolute margin CE in contrast to our PERM CE.

So the answer is probably yes. For shallow models, they are equivalent. See jupyter_notebooks/03_comparing_cross_entropy_implementations.ipynb for a demonstration. It can be proved that relative and absolute margin cross entropies result in the same optimization trajectories for convex models.

However, the PERM CE is strictly convex while the absolute margin CE is not. Whether this leads to any differences when training deep models is, the jury is still out.

Why another implementation of the cross entropy?

Since the multiclass hinges (DKR, WW, and CS) losses are implemented in the PERM loss framework, it's handy to implement the cross entropy also in this framework. It makes for easy apple-to-apple comparison. However, in the future, it may be useful to implement the absolute margin versions of these losses as well.

What is the theory behind PERM loss?

See jupyter_notebooks/01_introduction_to_PERM_losses.ipynb.

tf_multiclass's People

Contributors

yutongwangumich avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Forkers

zshwuhan

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.