Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matrix multiplication order question #5

Open
tc64 opened this issue Apr 19, 2019 · 3 comments
Open

matrix multiplication order question #5

tc64 opened this issue Apr 19, 2019 · 3 comments

Comments

@tc64
Copy link

tc64 commented Apr 19, 2019

Hi, thanks for sharing your code! I read your paper and am wondering about the matrix multiplication order for the backward loss correction approach.

The paper says T^{-1} loss

In loss.robust, for backward, we have:

return -K.sum(K.dot(y_true, P_inv) * K.log(y_pred), axis=-1)

It looks to me like the order of matrix multiplication for P_inv and y_true should be switched. My guess is that I'm misunderstanding something, but would really appreciate if you could clarify.

Thanks!

@giorgiop
Copy link
Owner

giorgiop commented May 2, 2019

Have you tried with a simple example and check what changes if you switch the order?

@rosefun
Copy link

rosefun commented Jun 10, 2019

Hi, I'm confused about the calculation about the forward loss. In your paper, the forward loss should be shown as follows.
image

However, in the code, it's calculated as:
return -K.sum(y_true * K.log(K.dot(y_pred, P)), axis=-1). Why not use P.T instead of P.

@guixianjin
Copy link

guixianjin commented Oct 21, 2019

Hi! @tc64 @rosefun @giorgiop
I think it may be because y_pred shape is N(batch_size) * C(class_num). That is y_pred = [f(x1)^T;f(x2)^T;...] where f(x1) ( a column vector) is the classifier's prediction on exmaple x1.
Thus (P.T * f(x))^T = f(x)^T*P, so it's K.dot( y_pred, P)

And maybe size of y_true is also N(batch_size) * C(class_num), so it's K.dot(y_true, P_inv)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants