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

Add log_prob #62

Merged
merged 20 commits into from
Apr 10, 2019
Merged

Add log_prob #62

merged 20 commits into from
Apr 10, 2019

Conversation

masa-su
Copy link
Owner

@masa-su masa-su commented Mar 25, 2019

  • remove the log_likelihood function
  • add log_prob in Distribution API which performs as the instance of Loss API.
  • rename the LossExpectation class to Expectation and add the expectation method in Loss API.
  • rename the estimation method in Loss API to eval (according to model.eval() on PyTorch).
  • remove flow implementations for now.

@masa-su
Copy link
Owner Author

masa-su commented Mar 25, 2019

Example code

>> print(q)
Distribution:
  q(z|x) (Normal)
Network architecture:
  Inference(
    (fc1): Linear(in_features=784, out_features=512, bias=True)
    (fc2): Linear(in_features=512, out_features=512, bias=True)
    (fc31): Linear(in_features=512, out_features=64, bias=True)
    (fc32): Linear(in_features=512, out_features=64, bias=True)
  )

>> print(q.log_prob())
log q(z|x)  # log-probability density function(Loss API)

>> samples_dict = q.sample({"x": _x})
>> loss = q.log_prob().mean().eval(samples_dict)
>> print(loss)
tensor(-67.4651, device='cuda:0', grad_fn=<MeanBackward1>)

>> loss = ((p * prior).log_prob() - q.log_prob()).expectation(q).mean()  # = Expectation(q, (p * prior).log_prob() - q.log_prob()).mean()
>> print(loss)
mean(E_q(z|x)[log p(x,z) - log q(z|x)])

@masa-su masa-su changed the title [WIP] Add log_prob Add log_prob Apr 10, 2019
@masa-su masa-su merged commit e27a4e1 into develop/v0.0.6 Apr 10, 2019
@masa-su masa-su deleted the add_log_prob branch April 10, 2019 09:09
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

Successfully merging this pull request may close these issues.

1 participant