[英]Python numpy array index can be -1?
我正在嘗試從https://github.com/Itseez/opencv/blob/master/samples/python2/letter_recog.py獲取 opencv示例,我需要幫助來解密此代碼。
new_samples = np.zeros((sample_n * self.class_n, var_n+1), np.float32)
new_samples[:,:-1] = np.repeat(samples, self.class_n, axis=0)
new_samples[:,-1] = np.tile(np.arange(self.class_n), sample_n)
我知道np.repeat
和np.tile
是什么,但是我不確定使用-1索引應該做什么new_samples[:,:-1]
或new_samples[:,-1]
。 我知道numpy
數組索引的工作原理,但是沒有看到這種情況。 我無法通過搜索找到解決方案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.