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

Doubt about the integral calculating function. #3

Open
caojiangxia opened this issue Nov 17, 2020 · 2 comments
Open

Doubt about the integral calculating function. #3

caojiangxia opened this issue Nov 17, 2020 · 2 comments

Comments

@caojiangxia
Copy link

def compute_integral_unbiased(model, data, time, non_pad_mask, type_mask):
""" Log-likelihood of non-events, using Monte Carlo integration. """

num_samples = 100

diff_time = (time[:, 1:] - time[:, :-1]) * non_pad_mask[:, 1:]
temp_time = diff_time.unsqueeze(2) * \
            torch.rand([*diff_time.size(), num_samples], device=data.device)
temp_time /= (time[:, :-1] + 1).unsqueeze(2)

temp_hid = model.linear(data)[:, 1:, :]
temp_hid = torch.sum(temp_hid * type_mask[:, 1:, :], dim=2, keepdim=True)

all_lambda = F.softplus(temp_hid + model.alpha * temp_time, threshold=10)
all_lambda = torch.sum(all_lambda, dim=2) / num_samples

unbiased_integral = all_lambda * diff_time
return unbiased_integral

For my understanding ,

temp_hid = torch.sum(temp_hid * type_mask[:, 1:, :], dim=2, keepdim=True)
->
temp_hid = torch.sum(temp_hid, dim=2, keepdim=True)

@caojiangxia caojiangxia changed the title The integral calculating function seems wrong. Doubt about the integral calculating function. Nov 18, 2020
@DavidZhang88
Copy link

There is no error of this part,
the lentgth of temp_hid = torch.sum(temp_hid, dim=2, keepdim=True) is not equal to diff_time, maybe you could check it again.

@caojiangxia
Copy link
Author

Thanks for your reply! I just doubt the integral function T_T. For my understanding, when we minimize the LAMBDA=\int \sum lambda_k, the type mask should be removed? The type mask just needs at the maximizing loglikelihood function part(just maximizing lambda_k at time t).

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

2 participants