Closed freddycct closed 6 years ago
@freddycct Hinge loss is used in binary classification. In the case the prediction is a real number (for two classes +/- 1). It does not work in multi-class case.
@pluskid, I know that, my labels are float32(1.0) and float32(-1.0). It's definitely a bug there.
My program works for the GPU backend but fails for CPU backend.
I should add that I am also doing image classification, but only for two classes.
In the case of binary prediction, m
and n
should be equal, so the problem you described does not sound like binary prediction. Can you provide a minimum runnable example to reproduce the bug?
Here's the zip file. It's basically LeNet but using hingeloss layer at the end. If you enable the GPU backend, you can see that it works fine..
@pluskid I hope you can help me with this bug. Please look at this piece of code at line 63 or hinge-loss.jl
The problem here is that n != m and n and m should be the batch_size of the training_data. So when i reaches i > n, there will be an out of bounds error. This bug however, does not appear when the GPU backend is used.
Infact, n is a constant 500 while m is the batch_size
Similarly, the backward function also has the same problem at line 85 of the same file.
assuming that i set n=length(label) for both forward and backward function, i get an error at
Sorry if this seems like a lot to understand!