Skip to content

weight use for loss function #14

Closed
@xxxfrank

Description

@xxxfrank

image
i wonder how to calculate the weight if i train with another dataset.
(i have tried 1/pixel frequency of each class ,but it works bad : (

Thanks

Activity

PkuRainBow

PkuRainBow commented on Sep 26, 2018

@PkuRainBow
Collaborator

@xxxfrank Hi, we compute the weights by 1/log(pixel_count).

eugenelawrence

eugenelawrence commented on Nov 1, 2018

@eugenelawrence

@PkuRainBow What do the pixel_count mean? Is it the pixel count of the specific class across the dataset? If so, the pixel_count corresponds to loss_weight 0.8373 should be exp(1/0.8373)=3.3013. It's weird!
Correct me if I have anywhere misunderstood.

PkuRainBow

PkuRainBow commented on Nov 2, 2018

@PkuRainBow
Collaborator

@eugenelawrence

Thanks for your interest in our work.

We will update the explaination of these weights in our update paper.

Please keep waiting for the arXiv update. We will notice you in the earliest time.

eugenelawrence

eugenelawrence commented on Nov 2, 2018

@eugenelawrence

@PkuRainBow
I am wondering would you release the code for calculating the loss weights?

PkuRainBow

PkuRainBow commented on Nov 2, 2018

@PkuRainBow
Collaborator

@PkuRainBow
I am wondering would you release the code for calculating the loss weights?

Of course if you need.

KeyKy

KeyKy commented on Jan 2, 2019

@KeyKy

@PkuRainBow So, How did you compute the loss weight?

PkuRainBow

PkuRainBow commented on Jan 3, 2019

@PkuRainBow
Collaborator

@KeyKy @eugenelawrence @xxxfrank Here we employ the log function firstly,

image

Then, we will apply L1-normalize over all the log weights w to act as the final weights.

Here I provide the statistics of the pixels' count on the Cityscapes' training set.

image

yyfyan

yyfyan commented on Jan 4, 2019

@yyfyan

Hi, @PkuRainBow
I used the code to Cal. but this is defferent.
`D = [2.01e+9,2.98e+8,9.96e+8,3.39e+7,4.50e+7,6.54e+7,
9.57e+7,2.62e+7,7.21e+8,5.92e+7,1.45e+8,8.21e+7,
1.00e+7,4.13e+8,1.45e+7,1.28e+7,1.45e+7,5.64e+6,
2.57e+7]

w = np.log(D)/np.log(19)
print(w)
w_sum = np.sum(w)
print(w_sum)
w = w/w_sum
print(w)`

PkuRainBow

PkuRainBow commented on Sep 5, 2019

@PkuRainBow
Collaborator

image

Anikily

Anikily commented on Oct 8, 2019

@Anikily

@PkuRainBow Could you tell me how to calculate the pixel_count on training dataset?

AndyChang666

AndyChang666 commented on Dec 16, 2020

@AndyChang666

@PkuRainBow Could you release the code of calculating class_freq in the whole dataset? Thank you.

jianlong-yuan

jianlong-yuan commented on Mar 9, 2022

@jianlong-yuan

any news?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @KeyKy@PkuRainBow@eugenelawrence@jianlong-yuan@yyfyan

        Issue actions

          weight use for loss function · Issue #14 · openseg-group/OCNet.pytorch