1
2つの異なるデータ型uint8とint32の2つのnumpy配列をファイルにダンプしようとしています。異なるデータ型をnumpyを使用してファイルに保存する際のエラー
img.tofile(PATH + "add_info_to_img.dat")
# append array_with_info to the beginning of the file
f_handle = open(PATH + "add_info_to_img.dat", 'a')
np.savetxt(f_handle, array_with_info)
f_handle.close()
データ情報:
img.shape
Out[4]: (921600,)
array_with_info.shape
Out[5]: (5,)
array_with_info.dtype
Out[6]: dtype('int32')
img.dtype
Out[7]: dtype('uint8')
任意の提案私は、ファイルを書き込むために、次のコードを使用しています
File "C:\ENV\p34\lib\site-packages\numpy\lib\npyio.py", line 1162, in savetxt
% (str(X.dtype), format))
TypeError: Mismatch between array dtype ('int32') and format specifier ('%.18e')
:私は次のエラーを取得していますか?
これはおそらくあなたのデータに関連しています。私は同じタイプのダミーデータでこれを再現することはできません。おそらくデータを知る必要があるでしょう。 – languitar