KernelBinaryCategorizer Serialization

7 weergaven
Naar het eerste ongelezen bericht

Stephen Mallette

ongelezen,
4 okt 2013, 10:49:1904-10-2013
aan cognitiv...@googlegroups.com
I was trying to serialize the gov.sandia.cognition.learning.function.categorization.KernelBinaryCategorizer and ran into a problems with it...here's the probably not so useful exception I'm getting:

java.io.NotSerializableException: java.util.HashMap$Values
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)

According to the API, it appears to be marked Serializable:


Any thoughts on what might be amiss here?  Also, more generally, is it a safe expectation that "categorizer" classes in the foundry are all meant to be serializable so that they can be written to disk and saved for future usage?

Thanks,

Stephen




Justin Basilico

ongelezen,
6 okt 2013, 00:05:3606-10-2013
aan cognitiv...@googlegroups.com
Hi Stephen,

It looks like maybe one of the SVM algorithms is storing the support vectors as values from a HashMap, which is breaking the serialization. Which learning algorithm are you using? 

A quick work-around is to take the learned KernelBinaryCategorizer and change the "example" collection by doing something like:
KernelBinaryCategorizer<T, E> learned = ...;
learned.setExamples(CollectionUtil.asArrayList(learned.getExamples());

The ArrayList should be serializable while the HashMap$Values may not be.

Let me know if that works.

Thanks,
Justin



--
You received this message because you are subscribed to the Google Groups "Cognitive Foundry" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cognitive-foun...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Justin Basilico

ongelezen,
6 okt 2013, 00:12:5406-10-2013
aan cognitiv...@googlegroups.com
It looks like SMO could be exhibiting this behavior, so I changed it to do this automatically after learning.

Thanks, : )
Justin

Stephen Mallette

ongelezen,
6 okt 2013, 09:14:1206-10-2013
aan cognitiv...@googlegroups.com
It was SMO.  Your workaround for converting the HashMap$Values fixed the problem. 

Thanks,

Stephen
Allen beantwoorden
Auteur beantwoorden
Doorsturen
0 nieuwe berichten