Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

[BUG] cross_entropy_with_selfnorm

Open yu239-zz opened this issue 9 years ago • 1 comments

Currently this cost layer assumes that the input is already softmax normalized (i.e., sum-to-one). Thus the second line of the following code is wrong:

Matrix::resizeOrCreate(sftMaxSum_, output.getHeight(), 1, false, useGpu_);                                                                                                                                                       
output.rowSum(*sftMaxSum_);                                                                                                                                                                                                      
sftMaxSum_->log2();          

Because the rowSum is always 1. I think this layer needs the non-normalized vector as the input so that it is able to sum the normalizer.

yu239-zz avatar Jan 06 '17 06:01 yu239-zz

Sorry I understand this in a wrong way. The input can be a vector of all positive numbers, for example, after taking exp(). In this case, this cost layer makes sense. Anyway, I think the code comment should be more detailed so that the use of this layer is clarified.

yu239-zz avatar Jan 06 '17 19:01 yu239-zz