StevenBanama / C3AE

C3AE implement
BSD 2-Clause "Simplified" License
86 stars 16 forks source link

About age dist #5

Closed MoonBunnyZZZ closed 4 years ago

MoonBunnyZZZ commented 4 years ago

The scale of focal loss defined in nets/utils.py, line 114 to line 117. total_num = float(sum(classes_num)) classes_w_t1 = [ total_num / ff for ff in classes_num ] sum_ = sum(classes_w_t1) classes_w_t2 = [ ff/sum_ for ff in classes_w_t1 ] #scale classes_w_tensor = tf.convert_to_tensor(classes_w_t2, dtype=prediction_tensor.dtype) The classes_num is age distribution of one batch, kind of age histogram.It seems like that some ff may be zero.I think some small amout, like 1e-2 should be added to ff. @StevenBanama

StevenBanama commented 4 years ago

@MoonBunnyZZZ You are right。 But classes_num is list in script which descripts the distribution of all bins. ff is 0 , which means that no sample exists in that class. On the other hand, that class is useless. In this task, the examples of each bin is great than zero. Here is a small trick in my code.

age_dist = [trainset["age"][(trainset.age >= x -10) & (trainset.age <= x)].count() for x in xrange(10, 101, 10)]
age_dist = [age_dist[0]] + age_dist + [age_dist[-1]]  # each bin has more than zeros, even in the tail or head node
MoonBunnyZZZ commented 4 years ago

@MoonBunnyZZZ You are right。 But classes_num is list in script which descripts the distribution of all bins. ff is 0 , which means that no sample exists in that class. On the other hand, that class is useless. In this task, the examples of each bin is great than zero. Here is a small trick in my code.

age_dist = [trainset["age"][(trainset.age >= x -10) & (trainset.age <= x)].count() for x in xrange(10, 101, 10)]
age_dist = [age_dist[0]] + age_dist + [age_dist[-1]]  # each bin has more than zeros, even in the tail or head node

@StevenBanama Thank you for your replay. I still don't why each bin is great than zero .Because I think that, in one batch, no sample age exist in some age groups, for example 10~20.So zero exists in list age_dist.

StevenBanama commented 4 years ago

@MoonBunnyZZZ you‘d beter read the papper about focal loss, the focal scale is build on the distribution of whole dataset, not a batch size.