def upper_triangular_to_array(A):
    N = A.shape[0]
return np.array([p for i, p in enumerate(A.flatten()) if i > i / N * (1 + N)])
Convert the strictly upper triangular part of a matrix into an array in Tensorflow