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

Why choose the last column of Q0, Q1 and g #4

Open
zyxnlp opened this issue Jun 27, 2022 · 0 comments
Open

Why choose the last column of Q0, Q1 and g #4

zyxnlp opened this issue Jun 27, 2022 · 0 comments

Comments

@zyxnlp
Copy link

zyxnlp commented Jun 27, 2022

Hi Reid, thanks for your implementation. I have two questions about the code.

I was wondering why the last column of Q0, Q1, and g was selected in the code of lines 165-167.

Q0 = sm(Q_logits_T0)[:, 1]
Q1 = sm(Q_logits_T1)[:, 1]
g = sm(g)[:, 1]

Would that be equal to calculate the P(Y=1 |T=0, C, text) and P(Y=1 |T=1, C, text) and P(T=1 | C, text)?

However, according to the definition in the paper, what we should calculate are P(Y|T=0, C, text), P(Y |T=1, C, text), and P(T | C, text) ? Please correct me if I'm wrong.

Another question is why the Y labels of T=0 and T=1 should be set to -100 when calculating the cross-entropy of Q1 and Q0?

T0_indices = (T == 0).nonzero().squeeze()
Y_T1_labels = Y.clone().scatter(0, T0_indices, -100)
T1_indices = (T == 1).nonzero().squeeze()
Y_T0_labels = Y.clone().scatter(0, T1_indices, -100)
Q_loss_T1 = CrossEntropyLoss()(Q_logits_T1.view(-1, self.num_labels), Y_T1_labels)
Q_loss_T0 = CrossEntropyLoss()(Q_logits_T0.view(-1, self.num_labels), Y_T0_labels)

I'm a freshman in causal inference. Really appreciated it if you can help me out!

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

1 participant