title: broadcast error : optimal transport library
body: <p>I'm doing a Barycenter clustering. but why this error? Looks like something bad happened when doing matrix multiplications.</p>
  
  <pre><code>import numpy as np
  import pandas as pd
  import ot
  
  def initialize_clusters(points, k):
      return points[np.random.randint(points.shape[0], size=k)]
  
  def get_distances(centroid, points):
      return np.linalg.norm(points - centroid, axis=1)
  
  if __name__ == "__main__":
      X = pd.read_csv('./csv/inst_clust2.csv',encoding='utf-8')[['lat','lng']]
      M = ot.dist(X,metric='euclidean')
      X = X.as_matrix()
      k = 3
      maxiter = 50
      centroids = initialize_clusters(X,k)
      classes = np.zeros(X.shape[0],dtype=np.float64)
      distances = np.zeros([X.shape[0],k],dtype=np.float64)
      for i in range(maxiter):
          for i, c in enumerate(centroids):
              distances[:,i] = get_distances(c, X)
          classes = np.argmin(distances,axis=1)
          for c in range(k):
              print(X)
              print(X[classes==c])
              centroids[c]=ot.barycenter(X[classes==c],M,1e-3)
  </code></pre>
  
  <p>gives error </p>
  
  <pre><code>/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ot/bregman.py:801: RuntimeWarning: invalid value encountered in log
    return np.exp(np.mean(np.log(alldistribT), axis=1))
  Traceback (most recent call last):
    File "/Users/Chu/Documents/dssg2018/bc.py", line 25, in &lt;module&gt;
      centroids[c]=ot.bregman.barycenter(X[classes==c],M,1e-3)
  ValueError: could not broadcast input array from shape (605) into shape (2)
  </code></pre>