kernels.py 文件源码

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

项目:MKLMM 作者: omerwe 项目源码 文件源码
def deriveKernel(self, params, i):
        self.checkParamsI(params, i)
        ell = np.exp(params[0])
        p = np.exp(params[1])

        #compute d2
        if (self.K_sq is None): d2 = sq_dist(self.X_scaled.T / ell) #precompute squared distances
        else: d2 = self.K_sq / ell**2

        #compute dp
        dp = self.dp/p

        K = np.exp(-d2 / 2.0)
        if (i==0): return d2*K*np.cos(2*np.pi*dp)
        elif (i==1): return 2*np.pi*dp*np.sin(2*np.pi*dp)*K
        else: raise Exception('invalid parameter index:' + str(i))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号