我将在Matlab中生成的二进制图像矩阵导入到python3脚本中,以便使用Keras运行TensorFlow。图像矩阵大于2 2GB,是4维的。我可以通过命令窗口在Matlab中加载:
>> load('imageMatrix.mat')
>> size(imageMatrix)
ans =
200 200 1 60000运行python脚本和notebook文件时出现错误:TypeError: unhashable type: 'slice'
有没有可能使用Keras将这样一个大于2 2GB的矩阵导入到TensorFlow?
我尝试使用"hdf5storage“将其加载到Jupyter notebook中,得到错误:TypeError: unhashable type: 'slice'
import hdf5storage
#imageMatrix =hdf5storage.loadmat('imageMatrix.mat')
hdf5storage.loadmat('imageMatrix.mat')
shapeOfImagaMatrix=np.shape(imageMatrix)
plt.imshow(imageMatrix[:,:,1,15])
plt.savefig('Visul_Image_M=80.pdf')发布于 2019-08-30 03:42:01
imageMatrix['imageMatrix']值的第三个维度的长度似乎只有1,因此这里的修复方法似乎是通过imageMatrix['imageMatrix'][:,:,0,15]对其进行索引。
发布于 2019-08-26 22:44:46
您是否尝试过检查loadmat()函数是否返回一个带有键的字典来拉出图像?我知道在加载值表时,如果MATLAB中的表变量有不同的名称,这可能是一个问题。在这种情况下,从loadmat()返回的值(在本例中为imageMatrix )将有一个用于提取数据的键。
如果确实发生了这种情况,可以通过对返回值调用.keys()来打印密钥。
https://stackoverflow.com/questions/57453108
复制相似问题