Ejemplo n.º 1
0
 def _update_labels(self, mu, Sigma, weights, ident=False):
     if self.gpu:
         # GPU business happens?
         return get_labelsGPU(self.gpu_workers, weights, mu, Sigma, relabel=ident)
     else:
         densities = mvn_weighted_logged(self.data, mu, Sigma, weights)
         if ident:
             Z = np.asarray(densities.argmax(1), dtype='i')
         else:
             Z = None
         return sample_discrete(densities).squeeze(), Z
Ejemplo n.º 2
0
    def _update_labels(self, mu, Sigma, weights):
        # gets the latent classifications .. easily done with current multigpu
        zhat = []
        if self.gpu:
            return get_hdp_labels_GPU(self.gpu_workers, weights, mu, Sigma, self._ident)

        else:
            labels = [np.zeros(self.nobs[j]) for j in range(self.ngroups)]
            for j in xrange(self.ngroups):
                densities = mvn_weighted_logged(self.data[j], mu, Sigma, weights[j])
                labels[j] = sample_discrete(densities).squeeze()
                if self._ident:
                    zhat.append(np.asarray(densities.argmax(1), dtype='i'))

        return labels, zhat
Ejemplo n.º 3
0
    def _update_labels(self, mu, Sigma, weights):
        # gets the latent classifications .. easily done with current multigpu
        zhat = []
        if self.gpu:
            return get_hdp_labels_GPU(self.gpu_workers, weights, mu, Sigma, self._ident)

        else:
            labels = [np.zeros(self.nobs[j]) for j in range(self.ngroups)]
            for j in xrange(self.ngroups):
                densities = mvn_weighted_logged(self.data[j], mu, Sigma, weights[j])
                labels[j] = sample_discrete(densities).squeeze()
                if self._ident:
                    zhat.append(np.asarray(densities.argmax(1), dtype='i'))

        return labels, zhat
Ejemplo n.º 4
0
 def _update_labels(self, mu, Sigma, weights, ident=False):
     if self.gpu:
         # GPU business happens?
         return get_labelsGPU(self.gpu_workers,
                              weights,
                              mu,
                              Sigma,
                              relabel=ident)
     else:
         densities = mvn_weighted_logged(self.data, mu, Sigma, weights)
         if ident:
             Z = np.asarray(densities.argmax(1), dtype='i')
         else:
             Z = None
         return sample_discrete(densities).squeeze(), Z