KernelBinaryCategorizer Serialization

11 views
Skip to first unread message

Stephen Mallette

unread,
Oct 4, 2013, 10:49:19 AM10/4/13
to 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

unread,
Oct 6, 2013, 12:05:36 AM10/6/13
to 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

unread,
Oct 6, 2013, 12:12:54 AM10/6/13
to 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

unread,
Oct 6, 2013, 9:14:12 AM10/6/13
to cognitiv...@googlegroups.com
It was SMO.  Your workaround for converting the HashMap$Values fixed the problem. 

Thanks,

Stephen
Reply all
Reply to author
Forward
0 new messages