def _calculate_log_probability(self, x, **parameters): """ One line description Parameters ---------- Returns ------- """ vector_shape = parameters[ "p"].shape if "p" in parameters else parameters["softmax_p"].shape if x.shape == vector_shape and tensor_range(x) == {0, 1}: dist = distributions.one_hot_categorical.OneHotCategorical else: dist = distributions.categorical.Categorical if "p" in parameters: log_prob = dist(probs=parameters["p"]).log_prob(x[:, 0]) elif "softmax_p" in parameters: log_prob = dist(logits=parameters["softmax_p"]).log_prob(x[:, 0]) else: raise ValueError("Either p or " + "softmax_p needs to be provided as input") return log_prob
def _calculate_log_probability(self, x, **parameters): """ One line description Parameters ---------- Returns ------- """ vector_shape = parameters["probs"].shape if "probs" in parameters else parameters["logits"].shape if x.shape == vector_shape and tensor_range(x) == {0, 1}: dist = self.torchdist else: dist = distributions.categorical.Categorical log_prob = dist(**parameters).log_prob(x[:, 0]) return log_prob