save weights to "toy.weights" doesn't work.

7 views
Skip to first unread message

don.tu...@gmail.com

unread,
Feb 24, 2014, 6:12:05 AM2/24/14
to thebeast...@googlegroups.com
Dear all,

I'm trying to save weights after learning in the non-binary format. However, i get an error message:
# save weights to "toy.weights";
Error on line 0: save weights to !ERROR!"toy.weights";

However, I can save to the binary format with
# save weights to dump "toy.weights";
335 weights saved.

Has anyone experienced this problem?

Thanks & best
Don

The long story: 
I'm using thebeast as an instance classifier in a python environment using the subprocess modul and write commands to it through PIPE from python. 
thebeast=subprocess.Popen(['thebeast'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)      #staring thebeast
thebeast.stdin.write('set solver.model.solver = "gurobi";include "types.pml";include "coref.pml";set solver.model.initIntegers = true;load weights from dump "toy.weights";\n')    #loading the model

I then write a file "test.atoms" (in python) and pass this file to the running thebeast:
thebeast.stdin.write('load corpus from "test.atoms";save corpus to ram;next; solve;print atoms.coref;\n')   #testing an instance
and read back in thebeast output, and so forth.

What I noticed is that loading the weights from a dump can be problematic when the training instances are not present. I.e. if I start thebeast and do
include "types.pml";include "coref.pml";set solver.model.initIntegers = true;load weights from dump "toy.weights";print weights;
I get the error:

>w_animacy
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:571)
at java.util.ArrayList.get(ArrayList.java:349)
at thebeast.nodmem.type.MemCategoricalType.representation(MemCategoricalType.java:45)
at thebeast.nodmem.value.MemCategorical.representation(MemCategorical.java:29)
at thebeast.nod.util.TabularValuePrinter.visitCategorical(TabularValuePrinter.java:59)
at thebeast.nodmem.value.MemCategorical.acceptValueVisitor(MemCategorical.java:25)
at thebeast.nod.util.TabularValuePrinter.visitTuple(TabularValuePrinter.java:32)
at thebeast.nodmem.value.MemTuple.acceptValueVisitor(MemTuple.java:34)
at thebeast.nod.util.TabularValuePrinter.visitRelation(TabularValuePrinter.java:52)
at thebeast.nodmem.value.MemRelation.acceptValueVisitor(MemRelation.java:64)
at thebeast.nodmem.value.MemRelation.writeTo(MemRelation.java:81)
at thebeast.pml.Weights.save(Weights.java:185)
at thebeast.pml.Weights.save(Weights.java:161)
at thebeast.pml.parser.Shell.visitPrint(Shell.java:541)
at thebeast.pml.parser.ParserPrint.acceptParserStatementVisitor(ParserPrint.java:15)
at thebeast.pml.parser.Shell.interactive(Shell.java:186)
at thebeast.pml.TheBeast.main(TheBeast.java:107)

It seems that the constants aren't instantiated properly.. I also noticed that formulas with different constant values can display different weights for the same constant combination given different test instances. I assume there is a problem with loading the weighs from dumps when the instances from which the weights were inferred aren't in memory..

Reply all
Reply to author
Forward
0 new messages