diff --git a/gensim/models/keyedvectors.py b/gensim/models/keyedvectors.py index 3dd6cf61d0..475a0b4810 100644 --- a/gensim/models/keyedvectors.py +++ b/gensim/models/keyedvectors.py @@ -495,9 +495,9 @@ def get_mean_vector(self, keys, weights=None, pre_normalize=True, post_normalize if len(keys) == 0: raise ValueError("cannot compute mean with no input") if isinstance(weights, list): - weights = np.array(weights) + weights = np.array(weights, dtype=self.vectors.dtype) if weights is None: - weights = np.ones(len(keys)) + weights = np.ones(len(keys), dtype=self.vectors.dtype) if len(keys) != weights.shape[0]: # weights is a 1-D numpy array raise ValueError( "keys and weights array must have same number of elements" diff --git a/gensim/models/ldamodel.py b/gensim/models/ldamodel.py index 945ff04599..c3e8afbf85 100755 --- a/gensim/models/ldamodel.py +++ b/gensim/models/ldamodel.py @@ -133,10 +133,11 @@ def update_dir_prior(prior, N, logphat, rho): The updated prior. """ + dtype = logphat.dtype gradf = N * (psi(np.sum(prior)) - psi(prior) + logphat) - c = N * polygamma(1, np.sum(prior)) - q = -N * polygamma(1, prior) + c = N * polygamma(1, np.sum(prior)).astype(dtype) + q = -N * polygamma(1, prior).astype(dtype) b = np.sum(gradf / q) / (1 / c + np.sum(1 / q))