Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question on weighted_bce loss #12

Open
songkq opened this issue May 31, 2020 · 0 comments
Open

question on weighted_bce loss #12

songkq opened this issue May 31, 2020 · 0 comments

Comments

@songkq
Copy link

songkq commented May 31, 2020

Hey,
As for the tensors y_true and y_pred with a shape of [1, 256, 256, 1],
the class_loglosses is a tensor with a shape of [1] so that class_weights here cannot do anything when executing the following line weighted_bce = K.sum(class_loglosses * K.constant(class_weights))

def weighted_bce_dice_loss(y_true,y_pred):
    class_loglosses = K.mean(K.binary_crossentropy(y_true, y_pred), axis=[0, 1, 2])
    class_weights = [0.1, 0.9]
    weighted_bce = K.sum(class_loglosses * K.constant(class_weights))
    return weighted_bce + 0.5 * (dice_coef_loss(y_true, y_pred))

I wonder if there's a confusion for the weighted loss? Or it can be replaced with the K.weighted_binary_crossentropy within pos_weight for the positive samples? Any advice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant