def log_prior(self, leaf_values): return T.mean( log_normal(leaf_values, T.zeros_like(leaf_values, dtype='float32'), T.ones_like(leaf_values, dtype='float32'), self.embedding_size, dim=2))
values, times = T.variable(values), T.variable(times) values = tf.concat(0, [z, values]) harmonic = T.variable(create_harmonic(M)) a_batch_values = T.gather(values, a_idx) a_batch_times = T.gather(times, a_idx) b_batch_values = T.gather(values, b_idx) b_batch_times = T.gather(times, b_idx) harmonic_m = T.gather(harmonic, m - 1) time_delta = b_batch_times - a_batch_times normal_log_prob = log_normal(b_batch_times, a_batch_times, time_delta * 1.0 / 1) log_pt = (log_a(a_batch_times) + (A(a_batch_times) - A(b_batch_times)) * harmonic_m) tree_log_prob = tf.select(tf.cast(leaf_segment, 'bool'), T.zeros_like(a_batch_times), log_pt + tf.to_float(log_fac)) log_q_zx = log_normal(z, q_mu, q_sigma) p_network = Vector(D, placeholder=z, is_input=False) >> Repeat(Tanh(200), 2) p_mu_network = p_network >> Linear(X.shape[1]) p_mu = p_mu_network.get_outputs()[0].get_placeholder() p_sigma_network = p_network >> Linear(X.shape[1]) p_sigma = tf.sqrt(tf.exp(p_sigma_network.get_outputs()[0].get_placeholder())) log_p_xz = log_normal(x, p_mu, p_sigma)# + tf.reduce_sum(tree_log_prob) with T.session() as sess: batch = set(sample_minibatch(N, M)) subtree = tree.induced_subtree(batch) s = np.array([[a.get_node_id(), b.get_node_id(), int(b.is_leaf())] + b.get_node_stats() for a, b in subtree.get_segments()])
def log_likelihood(self, states, costs): return T.zeros_like(costs)
def _sample(self, num_samples): a = self.get_parameters('natural')[Stats.X] d = self.shape()[-1] gumbel_noise = Gumbel(T.zeros_like(a), T.ones_like(a)).sample(num_samples) return T.one_hot(T.argmax(a[None] + gumbel_noise, -1), d)