質問

I know this is very simple and I can't believe I haven't found anything on this anywhere but here it goes:

I have a large, high dimensional matrix in python that I want to save in .mat format (for matlab). I'm using the scipy.io.savemat method to save this matrix but it's always saved as double. I would like to save it as something of lower precision, like single or 16 bit float.

I convert the array to a low-precision data type before saving but it's always saved as double. Is there really no way of saving mat files in a lower-precision float type?

.savemat does not seem to take a dtype argument.

 import scipy as sp
 sp.io.savemat('test.mat', {'test': sp.array([0.001, 1, 1.004], dtype='Float16')})
役に立ちましたか?

解決

Apparently it needs to be either single or double. scipy.io.savemat() does not support other float precisions and it'll casually default to double if it doesn't like your dtype without warning.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top