richzhang / colorization

Automatic colorization using deep neural networks. "Colorful Image Colorization." In ECCV, 2016.
http://richzhang.github.io/colorization/
BSD 2-Clause "Simplified" License
3.34k stars 921 forks source link

Division by zero when class rebalancing ? #69

Closed nasdenkov closed 5 years ago

nasdenkov commented 5 years ago

Hey there ! I've generated my own priors for training based on my own dataset. The problem is that they contain zeros and when I put the exponent -1, like this self.prior_factor = self.mix ** -self.alpha, it generates Infinity values inside my vector because I'm essentially trying to divide by zero Any idea how to fix it would be much appreciated. Thanks !

richzhang commented 5 years ago

Maybe you can add an epsilon to it. There's also the focal loss paper which may be of interest.

nasdenkov commented 5 years ago

I found out that the images in my training set were not contributing enough to all of the identified pairs in the quantized ab space. Technically 87 of the 313 value pairs were unused. Therefore I just used the remaining 226 pairs inside the convex hull as my own hull for training and the priors for those 226 pairs and the problem was resolved. Not sure if it is the correct way to approach this. However, as far as I'm understanding your work so far, if I were to add an epsilon to the mixed distribution, the exponential will end up calculating a huge prior factor for a pixel encoding that actually didn't contribute at all. This will render incorrect prioritizations when backpropagating over the network, I would assume. if you disagree, I'd love to hear your opinion on the matter. You've done a fantastic job with this paper by the way, good work !