Пример #1
0
 def cov_function(X, X2):
     mean = tf.expand_dims(tf.slice(self.mean, [0, i],
                                    [self.input_dim, 1]),
                           axis=2)
     temp = np.power(2 * np.pi, self.input_dim / 2) \
         * tf.sqrt(rprod(self.variance[:, i])) \
         * tf.square(self.constant[i])
     return temp * tf.exp(-0.5 * self.sqdist(X, X2, self.variance[:, i])) \
         * tf.cos(rsum(mean * self.dist(X, X2), 0))
Пример #2
0
 def cov_function(X, X2): 
     sv = self.variance[:,i] + self.variance[:,j]
     cross_delay = tf.reshape(self.delay[:,i] - self.delay[:,j], [self.input_dim, 1, 1])
     cross_phase = self.phase[i] - self.phase[j]
     cross_var = (2 * self.variance[:,i] * self.variance[:,j]) / sv
     cross_mean = tf.reshape((self.variance[:,i] * self.mean[:,j] + self.variance[:,j] * self.mean[:,i]) / sv, [self.input_dim, 1, 1])
     cross_magnitude = self.constant[i] * self.constant[j] * tf.exp(-0.25*rsum(tf.square(self.mean[:,i] - self.mean[:,j]) / sv))
     alpha = np.power(2*np.pi, self.input_dim / 2) * tf.sqrt(rprod(cross_var)) * cross_magnitude
     
     return alpha * tf.exp(-0.5*self.sqdist(X + self.delay[:,i], X2 + self.delay[:,j], cross_var)) * tf.cos(rsum(cross_mean * (self.dist(X, X2) + cross_delay), axis = 0) + cross_phase)