kwotsin/TensorFlow-ENet

Wrong implementation of median frequency re-weighting.

nnop opened this issue · 2 comments

nnop commented

for i, j in label_to_frequency_dict.items():
j = sorted(j) #To obtain the median, we got to sort the frequencies
median_frequency = np.median(j) / sum(j)
total_frequency = sum(j) / total_pixels
median_frequency_balanced = median_frequency / total_frequency
class_weights.append(median_frequency_balanced)

The implementation is not consistent with that stated in (Eigen and Fergus, 2015) :

image

Reference:

  • D. Eigen and R. Fergus, “Predicting depth, surface normals and semantic labels with a common multi-scale convolutional architecture,” in ICCV, pp. 2650–2658, 2015.

Do you specifically refer to line 91 where the median is divided by sum(j)?

nnop commented

You should take the median of frequencies among all classes, not the median among all images of a single class. Meanwhile, not needing sorting before use np.median.