私が見ているコードは次のとおりです。
ids = np.delete(ids, np.concatenate([ids[-1]], np.where(ious > thresh)[0]))
さまざまな変数の値は次のとおりです。
ids: [3 2 0 1]
ious: [0. 0.65972222 0.65972222]
thresh: 0.5
の出力np.where(ious > [thresh])[0])
は[1 2]
私が得ているように見えるエラーは次のとおりです。
np.where(ious > [thresh])[0]))
TypeError: only integer scalar arrays can be converted to a scalar index
を除くすべての変数thresh
はnumpy
配列であると確信しています。それで、正確に何が間違っているのか。
In [187]: ids=np.array([3,2,0,1])
In [188]: ious=np.array([0. , 0.65972222, 0.65972222])
In [189]: thresh=0.5
テストwhere
:
In [190]: np.where(ious>thresh)
Out[190]: (array([1, 2]),)
In [191]: np.where(ious>thresh)[0]
Out[191]: array([1, 2])
In [192]: np.where(ious>[thresh])[0]
Out[192]: array([1, 2])
今concatenate
:
In [193]: np.concatenate([ids[-1]], np.where(ious > thresh)[0])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-193-c71c05bfaf15> in <module>
----> 1 np.concatenate([ids[-1]], np.where(ious > thresh)[0])
TypeError: only integer scalar arrays can be converted to a scalar index
In [194]: np.concatenate([ids[-1], np.where(ious > thresh)[0]])
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-194-91ed414d6d7c> in <module>
----> 1 np.concatenate([ids[-1], np.where(ious > thresh)[0]])
ValueError: zero-dimensional arrays cannot be concatenated
In [195]: np.concatenate([[ids[-1]], np.where(ious > thresh)[0]])
Out[195]: array([1, 1, 2])
今delete
:
In [196]: np.delete(ids,np.concatenate([[ids[-1]], np.where(ious > thresh)[0]]))
Out[196]: array([3, 1])
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加