promp.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:promplib 作者: baxter-flowers 项目源码 文件源码
def generate_trajectory(self, randomness=1e-10):
        """
        Outputs a trajectory
        :param randomness: float between 0. (output will be the mean of gaussians) and 1. (fully randomized inside the variance)
        :return: a 1-D vector of the generated points
        """
        newMu = self.meanW
        newSigma = self.sigmaW

        for viapoint in self.viapoints:
            PhiT = np.exp(-.5 * (np.array(map(lambda x: x - self.C, np.tile(viapoint['t'], (11, 1)).T)).T ** 2 / (self.sigma ** 2)))
            PhiT = PhiT / sum(PhiT)  # basis functions at observed time points

            # Conditioning
            aux = viapoint['sigmay'] + np.dot(np.dot(PhiT.T, newSigma), PhiT)
            newMu = newMu + np.dot(np.dot(newSigma, PhiT) * 1 / aux, (viapoint['obsy'] - np.dot(PhiT.T, newMu)))  # new weight mean conditioned on observations
            newSigma = newSigma - np.dot(np.dot(newSigma, PhiT) * 1 / aux, np.dot(PhiT.T, newSigma))

        sampW = np.random.multivariate_normal(newMu, randomness*newSigma, 1).T
        return np.dot(self.Phi.T, sampW)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号