コード例 #1
0
 def postX_from_chol(tc1, tc2, lm):
     """
     postX = (Lambda1 + S)^{-1}.(Lambda1_ij.*Mu_j + X^T_k.*S_kj;i.*X_j)
     """
     return blk_chol_inv(tc1,
                         tc2,
                         blk_chol_inv(tc1, tc2, lm),
                         lower=False,
                         transpose=True)
コード例 #2
0
 def symbsample_X(self, Y=None):
     Y = self.Y if Y is None else Y
     Nsamps, Tbins = Y.shape[0], Y.shape[1]
     
     TheChol = theano.clone(self.TheChol, replace={self.Y : Y})
     postX = theano.clone(self.postX, replace={self.Y : Y})
     normSamps = srng.normal([Nsamps, Tbins, self.xDim])
     noise, _ = theano.scan(lambda tc1, tc2, ns : blk_chol_inv(tc1, tc2, ns, lower=False, transpose=True), 
                         sequences=(TheChol[0], TheChol[1], normSamps))
     return postX + noise
コード例 #3
0
 def symbsample_Xalt(self, Y=None, X=None):
     if Y is None: Y = self.Y
     if X is None: X = self.lat_ev_model.get_X()
     Xgen = self.lat_ev_model.get_X()
     Nsamps, Tbins = Y.shape[0], Y.shape[1]
     
     TheChol = theano.clone(self.TheChol, replace={self.Y : Y, Xgen : X})
     postX = theano.clone(self.postX, replace={self.Y : Y, Xgen : X})
     normSamps = srng.normal([Nsamps, Tbins, self.xDim])
     
     noise, _ = theano.scan(lambda tc1, tc2, ns : 
                            blk_chol_inv(tc1, tc2, ns, lower=False, transpose=True), 
                            sequences=(TheChol[0], TheChol[1], normSamps))
     return postX, noise
コード例 #4
0
 def sample_noise(self, Ydata, Xdata, Nsamps=1):
     Xgen = self.lat_ev_model.get_X()
     N, T = Xdata.shape[0], Xdata.shape[1]
     normSamps = srng.normal([N, T, self.xDim])
     
     TheChol = self.TheChol
     
     noise, _ = theano.scan(lambda tc1, tc2, ns : 
                            blk_chol_inv(tc1, tc2, ns, lower=False, transpose=True), 
                            sequences=(TheChol[0], TheChol[1], normSamps))
     noise_vals = np.zeros((Nsamps, N, T, self.xDim))
     for samp in range(Nsamps):
         noise_vals[samp] = noise.eval({self.Y : Ydata, Xgen : Xdata})
         
     return noise_vals
コード例 #5
0
    def sample_postX(self):
        """
        """
        Nsamps, NTbins, xDim = self.Nsamps, self.NTbins, self.xDim
        prenoise_NxTxd = tf.random_normal([Nsamps, NTbins, xDim], dtype=DTYPE)

        aux_fn = lambda _, seqs: blk_chol_inv(
            seqs[0], seqs[1], seqs[2], lower=False, transpose=True)
        noise = tf.scan(fn=aux_fn,
                        elems=[
                            self.TheChol_2xxNxTxdxd[0],
                            self.TheChol_2xxNxTxdxd[1], prenoise_NxTxd
                        ],
                        initializer=tf.zeros_like(prenoise_NxTxd[0],
                                                  dtype=DTYPE))
        noisy_postX_ng = tf.add(self.postX_ng_NxTxd, noise, name='noisy_postX')
        noisy_postX = tf.add(self.postX_NxTxd, noise, name='noisy_postX')

        return noisy_postX, noisy_postX_ng
コード例 #6
0
 def postX_from_chol(tc1, tc2, lm):
     """
     postX = (Lambda1 + Lambda2)^{-1}.Lambda1.Mu
     """
     return blk_chol_inv(tc1, tc2, blk_chol_inv(tc1, tc2, lm), lower=False, transpose=True)
コード例 #7
0
 def postX_from_chol(tc1, tc2, lm):
     return blk_chol_inv(tc1, tc2, blk_chol_inv(tc1, tc2, lm))