[問題] 2Dimensional Numpy array 找unique rows
這是udacity deep learning course 其中一個problem
找unique rows 這是網上找到的一個方法
def unique_rows(a):
a = np.ascontiguousarray(a)
unique_a = np.unique(a.view([('', a.dtype)]*a.shape[1]))
return unique_a.view(a.dtype).reshape((unique_a.shape[0], a.shape[1]))
三個關鍵的Numpy function:
ascontiguousarray
view
unique
其中我完全了解unique 但我不了解ascontiguousarray 和 view
跪求大家指教
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 50.185.236.143
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1468089424.A.D48.html
Python 近期熱門文章
PTT數位生活區 即時熱門文章