gemmr.util.align_weights

gemmr.util.align_weights(v, vtrue, copy=True, return_sign=False)

Align vectors in rows of v such that they have a positive dot-product with vtrue.

Parameters:
  • v (np.ndarray (.., n_features)) – each vector of length n_feature will be compared to vtrue and if the dot-product is negative will be multiplied by -1
  • vtrue (np.ndarray (n_features,)) – the reference vector
  • copy (bool) – whether a copy of v is made before signs are changed
  • return_sign (bool) – if True return signs of vector in addition to aligned vectors
Returns:

  • aligned (np.ndarray (n_vectors, n_features)) – aligned vectors
  • signed (np.ndarray (n_vectors, n_features)) – (only if return_sign == True). Signs (-1, 0 or 1) of original vectors