Windows下TypeError numpy.float64 object cannot be interpreted as an index的解决
来源:互联网 发布:C# js escape 编辑:程序博客网 时间:2024/06/05 19:22
在进行numpy-1.12.1操作的时候遇到了一个很郁闷的问题,在使用如下代码时,总是会产生一个这样的错误:TypeError numpy.float64 object cannot be interpreted as anindex。尝试了各种类型转换的方法都以无效而告终,我甚至一度怀疑我是不是装了一个假NumPy。
出错代码主要部分:
weights = ones(n) #m,n是只用shape函数返回的 dataMatrix的行数和列数for i in range(m):#alpha是常数,dataMatrix是二维数组 weights += alpha * weights * dataMatrix[i]#这个i就是罪恶的源泉
最后我的解决方案如下:
首先到Python的安装目录下,进入script中,然后再命令行执行:pip install -U numpy==1.11.0
我是已经安装了较高版本的NumPy的,所以会将先前的版本卸载,最后的情况如下:
降低版本后又遇到了其它的问题:
ValueError: operands could not be broadcast together withshapes…
两个数组A,B是<numpy.ndarray>类型,而不是<matrix>类型,直接进行乘积C = A*B, 将产生上述错误提示。解决方案,不用"*"符号,使用numpy中的dot()函数,可以实现两个二维数组的乘积(即C=dot(A,B)),或者将数组类型转化为矩阵类型,使用"*"相乘。
阅读全文
0 0
- Windows下TypeError numpy.float64 object cannot be interpreted as an index的解决
- TypeError numpy.float64 object cannot be interpreted as an index
- TypeError: 'numpy.float64' object cannot be interpreted as an index
- TypeError: 'numpy.float64' object cannot be interpreted as an index
- TypeError numpy.float64 object cannot be interpreted as an index
- TypeError: 'numpy.float64' object cannot be interpreted as an index
- TypeError numpy.float64 object cannot be interpreted as an index解决
- TypeError: 'numpy.float64' object cannot be interpreted as an integer
- TypeError: 'float' object cannot be interpreted as an integer
- python-Error Message: 'float' object cannot be interpreted as an integer
- python3中Error Message: ‘float’ object cannot be interpreted as an integer
- TypeError: 'numpy.float64' object is not iterablex
- python-TypeError: write() argument must be str, not numpy.float64
- 调试CRF出现的错误:cannot be interpreted as a Tensor.
- TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type s
- Pymongo - TypeError: index 'xxxx' cannot be applied to Cursor instances
- python write出现 Non-character array cannot be interpreted as character buffer.
- An entity object cannot be referenced by multiple instances of IEntityChangeTracker错误解决
- 嵌入式C语言基础—杂记一
- python实现数据离散化
- 信任报道
- 扩展gcd
- 【FUTURE】麻省理工科技评论-年度10大突破性技术-导读
- Windows下TypeError numpy.float64 object cannot be interpreted as an index的解决
- 13.常用的函数
- 设计模式之策略模式
- java基础(二)
- 【Arch】Android input系统之input命令
- arm开发板上arecord 录音出现噪声的解决方法
- git 提交代码到github中(4)
- 图
- [AVC(H.264)] x264 ratecontrol小记