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
def expected_labels(self): if self.gpu: self.ll, self.ct, self.xbar, self.densities = get_expected_labels_GPU( self.gpu_workers, self.weights, self.mu, self.Sigma) else: densities = mvn_weighted_logged(self.data, self.mu, self.Sigma, self.weights) densities = np.exp(densities) norm = densities.sum(1) self.ll = np.sum(np.log(norm)) densities = (densities.T / norm).T self.ct = densities.sum(0) self.xbar = np.dot(densities.T, self.data) self.densities = densities
def expected_labels(self): if self.gpu: self.ll, self.ct, self.xbar, self.densities = get_expected_labels_GPU( self.gpu_workers, self.weights, self.mu, self.Sigma) else: densities = mvn_weighted_logged(self.data, self.mu, self.Sigma, self.weights) densities = np.exp(densities) norm = densities.sum(1) self.ll = np.sum(np.log(norm)) densities = (densities.T / norm).T self.ct = densities.sum(0) self.xbar = np.dot(densities.T, self.data) self.densities = densities
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
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
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