我的内容如下:
[[array([175, 178, 182, ..., 172, 167, 164], dtype=uint8)
array(['b'], dtype='<U1')]
[array([126, 125, 126, ..., 152, 143, 137], dtype=uint8)
array(['b'], dtype='<U1')]]
当我试图保存上述内容时(比如
X
)详情如下:
np.savetxt('x.txt', X.reshape(np.shape(X)), fmt='%f')
我得到这个错误:
TypeError: Mismatch between array dtype ('object') and format specifier ('%f %f')
我知道改变
fmt='%s'
可能会解决这个问题,但另一个问题是,我将调用另一个不使用字符串的函数。
有什么办法可以救我吗
十、
在没有上述错误的情况下对文件进行修改?
谢谢。
编辑
自我执行以下操作后,已获得上述格式:
images.append([np.array(image_array_to_vector),np.array([label])])
X = np.array([[i[0],i[1]] for i in images])