def __call__(self, X):
ind = tf.gather(tf.transpose(X), tf.shape(X)[1]-1) # ind = X[:,-1]
ind = tf.cast(ind, tf.int32)
X = tf.transpose(tf.gather(tf.transpose(X), tf.range(0, tf.shape(X)[1]-1))) # X = X[:,:-1]
# split up X into chunks corresponding to the relevant likelihoods
x_list = tf.dynamic_partition(X, ind, self.num_meanfunctions)
# apply the likelihood-function to each section of the data
results = [m(x) for x, m in zip(x_list, self.meanfunction_list)]
# stitch the results back together
partitions = tf.dynamic_partition(tf.range(0, tf.size(ind)), ind, self.num_meanfunctions)
return tf.dynamic_stitch(partitions, results)
评论列表
文章目录