def _kl_divergence_bh(params, P, neighbors, degrees_of_freedom, n_samples, n_components, angle=0.5, skip_num_points=0, verbose=False):
 params = astype(params, np.float32, copy=False)
 X_embedded = params.reshape(n_samples, n_components)
 neighbors = astype(neighbors, np.int64, copy=False)
 if (len(P.shape) == 1):
  sP = squareform(P).astype(np.float32)
 else:
  sP = P.astype(np.float32)
 grad = np.zeros(X_embedded.shape, dtype=np.float32)
 error = _barnes_hut_tsne.gradient(sP, X_embedded, neighbors, grad, angle, n_components, verbose, dof=degrees_of_freedom)
 c = ((2.0 * (degrees_of_freedom + 1.0)) / degrees_of_freedom)
 grad = grad.ravel()
 grad *= c
 return (error, grad)

def _kl_divergence_bh ( params , P , neighbors , degrees_of_freedom , n_samples , n_components , angle = 0.5 , skip_num_points = 0 , verbose = False ) : params = astype ( params , np . float32 , copy = False ) X_embedded = params . reshape ( n_samples , n_components ) neighbors = astype ( neighbors , np . int64 , copy = False ) if ( len ( P . shape ) == 1 ) : sP = squareform ( P ) . astype ( np . float32 ) else : sP = P . astype ( np . float32 ) grad = np . zeros ( X_embedded . shape , dtype = np . float32 ) error = _barnes_hut_tsne . gradient ( sP , X_embedded , neighbors , grad , angle , n_components , verbose , dof = degrees_of_freedom ) c = ( ( 2.0 * ( degrees_of_freedom + 1.0 ) ) / degrees_of_freedom ) grad = grad . ravel ( ) grad *= c return ( error , grad )
t-sne objective function: kl divergence of p_ijs and q_ijs .