報(bào)錯(cuò)信息:
類(lèi)型錯(cuò)誤,只有整型標(biāo)量數(shù)組才能轉(zhuǎn)換成標(biāo)量索引,但一般問(wèn)題都不在于你的索引是不是整數(shù)。這個(gè)報(bào)錯(cuò)一般會(huì)出現(xiàn)在你想使用一個(gè)索引列表去索引另一個(gè)列表,即諸如list[index_list]的形式,此時(shí)就會(huì)出現(xiàn)此報(bào)錯(cuò),因?yàn)?index_list 為 List列表類(lèi)型,不被允許;如果是數(shù)組,則不會(huì)報(bào)錯(cuò)。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-511029.html
解決方法:
將想要索引的列表轉(zhuǎn)換為numpy數(shù)組,再對(duì)其進(jìn)行索引
如下:文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-511029.html
test_pos_u, test_pos_v = np.array(u)[np.array(eids)[:test_size]], np.array(v)[np.array(eids)[:test_size]]
train_pos_u, train_pos_v = np.array(u)[np.array(eids)[test_size:]], np.array(v)[np.array(eids)[test_size:]]
到了這里,關(guān)于TypeError: only integer scalar arrays can be converted to a scalar index的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!