Last active
January 17, 2017 00:35
-
-
Save dustinvtran/e00901a4b6154e08884b287f16e4c301 to your computer and use it in GitHub Desktop.
A template for implementing custom random variables in Edward.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from edward.models import RandomVariable | |
from tensorflow.contrib.distributions import Distribution | |
class Concrete(RandomVariable, Distribution): | |
def __init__(self, *args, **kwargs): | |
kwargs['is_continuous'] = True | |
kwargs['is_reparameterized'] = True | |
super(Concrete, self).__init__(*args, **kwargs) | |
def _log_prob(self, value): | |
# TODO | |
# https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/distributions/python/ops/distribution.py#L183 | |
raise NotImplementedError("log_prob is not implemented") | |
def _sample_n(self, n, seed=None): | |
# TODO it takes an integer n as input and outputs a tensor of shape | |
# (n,) + batch_shape + event_shape | |
# https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/distributions/python/ops/distribution.py#L557 | |
raise NotImplementedError("sample_n is not implemented") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment