在matlab中,我有一个程序,这个实现线性支持向量机来做机器学习。
库在训练阶段输出一个表示模型的结构。此结构将用于测试阶段。
我想将这个结构保存到一个文件中,这样我就不必每次都经历训练阶段。
我已经尝试过psychtoolbox的WriteStructsToText()
and ReadStructsFromText()
,但是由于在将结构读入内存时缓冲区溢出,它们失败了。
输出的结构是非常大量的数据(几十兆字节),所以这可能是问题所在。
结构:
-Parameters: Parameters
-nr_class: number of classes; = 2 for regression
-nr_feature: number of features in training data (without including the bias term)
-bias: If >= 0, we assume one additional feature is added to the end
of each data instance.
-Label: label of each class; empty for regression
-w: a nr_w-by-n matrix for the weights, where n is nr_feature
or nr_feature+1 depending on the existence of the bias term.
nr_w is 1 if nr_class=2 and -s is not 4 (i.e., not
multi-class svm by Crammer and Singer). It is
nr_class otherwise.
编辑:
有谁知道如何解决这个错误?
>> save('mode.txt','-struct','model');
>> model = load('mode.txt');
??? Error using ==> load
Number of columns on line 1 of ASCII file C:\Users\jason\Dropbox\Homework\cs280\FINAL PROJECTO\mode.txt
must be the same as previous lines.