Python 保存数组至.mat文件,报错:AttributeError: 'numpy.ndarray' object has no attribute 'items'
来源:互联网 发布:淘宝助理取消二次验证 编辑:程序博客网 时间:2024/06/05 06:08
Python保存数组的方式有很多种,如savetxt,但这个函数只能保存一维或二维数组。为了保存高维数组,同时能够在matlab载入,可以使用scipy.io.savemat()函数,例子:
import numpy as npimport scipy.io as sioA = np.array([[[1, 2], [3, 4]],[[5, 6], [7, 8]]])print Aprint A.shapesio.savemat('data.mat', {"foo":A})
得到输出:
在matlab中导入该数组:
>>load('data.mat')
可以看到,matlab与Python对矩阵的保存上有一定的变换,从Python到matlab为:’页’->’行’,’行’->’列’,’列’->’页’,即在Python中的矩阵形状为
另外,在Python中如果保存成.mat文件时代码为:sio.savemat('data.mat', A)
,则会报错AttributeError: 'numpy.ndarray' object has no attribute 'items'
阅读全文
0 0
- Python 保存数组至.mat文件,报错:AttributeError: 'numpy.ndarray' object has no attribute 'items'
- AttributeError: 'numpy.ndarray' object has no attribute 'value_counts'
- AttributeError: 'numpy.ndarray' object has no attribute 'index'
- 关于AttributeError:'numpy.ndarray' object has no attribute 'index'
- 'numpy.ndarray' object has no attribute 'values'
- python3 报错: AttributeError: 'module' object has no attribute 'urlopen'
- 报错AttributeError: 'module' object has no attribute 'HTTPSConnection'
- 报错 AttributeError: 'module' object has no attribute 'bool_'
- Tensorflow报错:AttributeError: 'module' object has no attribute 'summary'
- 【Tensorflow】报错:AttributeError: 'module' object has no attribute 'scalar_summary'
- import module报错AttributeError: 'module' object has no attribute
- Tensorflow报错:AttributeError: 'module' object has no attribute 'scalar_summary'
- pandas报错AttributeError: 'module' object has no attribute 'plotting'
- tensorflow报错:AttributeError: 'module' object has no attribute 'get_or_create_global_step'
- Python脚本报错AttributeError: ‘module’ object has no attribute ’urllibopen'(Python 2.7.11 )
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- python文件名不要跟模块名相同,报错AttributeError: 'module' object has no attribute 'Differ'
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Android7.0调用相机
- UDP协议发包的使用(DatagramSocket、DatagramPacket)
- C语言中的文件操作
- 百度竞价新人提升赚钱概率的技巧方法
- 润乾V4 行式填报流水号的设定
- Python 保存数组至.mat文件,报错:AttributeError: 'numpy.ndarray' object has no attribute 'items'
- spring data jpa 分页
- 修改 下载仓库为淘宝镜像 npm config set registry http://registry.npm.taobao.org/ 3, 如果要发布自己的镜像需要修改回来 npm
- 无人超市缤果盒子软件
- Hadoop学习——最大的敌人是自己
- shiro 简介
- awk打开多个文件的方法
- fetch = FetchType.EAGER
- 使用dig名令获得DNS报文