1
我面临从sdcard加载保存模型的问题。 在Weka的官方wiki中,我发现了两种反序列化序列化模型的方法,但其中没有一种适用于Android。如何在Weka-for-Android中反序列化保存的模型
//First Method
RandomForest rf = (RandomForest) weka.core.SerializationHelper.
read(Environment.getExternalStorageDirectory().getPath() + "/BC.model");
//Second Method
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(
Environment.getExternalStorageDirectory().getPath() + "/BC.model"));
RandomForest rf = new RandomForest();
rf = (RandomForest) ois.readObject();
我得到的logcat此错误:
java.io.InvalidClassException:
weka.classifiers.trees.RandomForest; Incompatible class (SUID):
weka.classifiers.trees.RandomForest
感谢Henry对你的回应:) 问题不在于我是否找到模型文件,我认为问题在于将ios.readObect转换为RandomForest。 我试图把它放在资产,但没有任何改变。 – 2013-05-29 15:38:14