分享

成功解决IndexError: shape mismatch: indexing arrays could not be broadcast together with shapes (100,)

 处女座的程序猿 2021-09-28

成功解决IndexError: shape mismatch: indexing arrays could not be broadcast together with shapes (100,)


解决问题

Index Error: shape mismatch: indexing arrays could not be broadcast together with shapes (100,) (100,10) 

解决思路

索引错误:形状不匹配:索引数组无法与形状(100,)一起广播(100,10)。
当使用其他整数类型的多维数组,访问numpy多维数组时,用于索引的数组需要具有相同的形状。numpy将会被允许去广播(如果可能的话),所以,若要为了实现这一点,数组需要具有相同的维数。

参考文章
Stack overflow:shape mismatch: indexing arrays could not be broadcast together with shapes
Indexing Multi-dimensional arrays

解决方法

使两个numpy数组保持形状一致即可!

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多