def sparse_to_tuple(sparse_mx):
    'Convert sparse matrix to tuple representation.'

    def to_tuple(mx):
        if (not sp.isspmatrix_coo(mx)):
            mx = mx.tocoo()
        coords = np.vstack((mx.row, mx.col)).transpose()
        values = mx.data
        shape = mx.shape
        return (coords, values, shape)
    if isinstance(sparse_mx, list):
        for i in range(len(sparse_mx)):
            sparse_mx[i] = to_tuple(sparse_mx[i])
    else:
        sparse_mx = to_tuple(sparse_mx)
    return sparse_mx
Convert sparse matrix to tuple representation.
def sparse_to_tuple(sparse_mx):
    

    def to_tuple(mx):
        if (not sp.isspmatrix_coo(mx)):
            mx = mx.tocoo()
        coords = np.vstack((mx.row, mx.col)).transpose()
        values = mx.data
        shape = mx.shape
        return (coords, values, shape)
    if isinstance(sparse_mx, list):
        for i in range(len(sparse_mx)):
            sparse_mx[i] = to_tuple(sparse_mx[i])
    else:
        sparse_mx = to_tuple(sparse_mx)
    return sparse_mx