Git Product home page Git Product logo

Comments (5)

argman avatar argman commented on July 4, 2024 1

You can use this one.

def weighted_cross_entropy(y_true_cls, y_pred_cls,
                           training_mask):
    # Loss for score Map
    epsilon = 10e-8
    # assume ratio of positive class is 0.1
    beta = 1.0 - 0.1
    # turn probabilities back to logits
    y_pred_cls = tf.clip_by_value(y_pred_cls, epsilon, 1 - epsilon)
    y_pred_cls = tf.log(y_pred_cls / (1. - y_pred_cls))
    Ls = (1. - beta) * tf.nn.weighted_cross_entropy_with_logits(targets=y_true_cls, logits=y_pred_cls,
                                                                pos_weight=beta / (1. - beta))
    Ls = tf.reduce_mean(Ls * training_mask)
    tf.summary.scalar('classification_logloss', Ls)
    return Ls

from east.

argman avatar argman commented on July 4, 2024

I donot recommend implement xentropylike this, you can use tf.nn.weighted_corss_entropy_with_logits

from east.

GodOfSmallThings avatar GodOfSmallThings commented on July 4, 2024

I need to implement class-balanced cross entropy function, and combine it with EAST. That's why I'm digging into it !

from east.

GodOfSmallThings avatar GodOfSmallThings commented on July 4, 2024

So if I want to implement class-balanced xentropy, is it okay to ignore training mask part?

from east.

GodOfSmallThings avatar GodOfSmallThings commented on July 4, 2024

I 'll try. Thank you very much for the answer!

from east.

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.