ExplainableML / czsl

PyTorch CZSL framework containing GQA, the open-world setting, and the CGE and CompCos methods.
GNU General Public License v3.0
111 stars 27 forks source link

Intuition of Eq. (8) in Open World Compositional Zero-Shot Learning #31

Closed xugy16 closed 1 year ago

xugy16 commented 1 year ago

Really appreciate for your work.

I have a question about Eq_8.

  1. For seen pairs, we just use cos score
  2. For unseen pairs, we need to adjust: 2.1 Feasible: fea_score will be closer to 1, then p(c) smaller, because minus fea_score 2.2 Unfeabsiel: ea_score will be closer to -1, then p(c) bigger

It should add fea_score instead of minus?

Did I miss something.

Thank you.

sgk98 commented 1 year ago

Thanks for the question. I would say that the intuition as as follows: During training, we want the model to learn to predict higher scores for feasible pairs and lower scores for infeasible pairs. A simple way to implement that is through Eq. 8, where if p(c)>0, then the model should learn to predict a higher score for it, whereas if p(c)<0, the model should learn to predict a lower score for it. I hope this helps.

mancinimassimiliano commented 1 year ago

Thanks @sgk98 for the answer and sorry @xugy16 for not replying before.

Indeed, the reason is the one @sgk98 pointed out. To explain it with an example, let's suppose there are 3 compositions: A (ground-truth for the current sample), B (feasible, score >0), and C (unfeasible, score <0).

Now, the classification loss (Eq. (7)) will penalize everything that is not A. Moreover, the higher the value predicted for a class different than A and the higher the penalization the model receives for such prediction.

What we want is that the loss penalizes more unfeasible compositions than feasible ones. We can achieve this by increasing the value predicted for the unfeasible composition C in such a way that it gets penalized more. Vice versa, we want to decrease the value predicted for the feasible composition B, such that the model gets penalized less by the loss.

Since the feasibility score is higher for feasible compositions, we need a - sign to achieve the effect we want.

Hope this helps.