|
18 | 18 | import mutil |
19 | 19 | import debug |
20 | 20 |
|
21 | | -VERSION = "1.0" |
| 21 | +VERSION = "1.0.01" |
22 | 22 |
|
23 | 23 | DEFAULT_MAXDEPTH=10 |
24 | 24 | DEFAULT_NORMALIZE='softmax' |
@@ -210,16 +210,19 @@ def loadRules(fileNames,db): |
210 | 210 | class Interp(object): |
211 | 211 | """High-level interface to tensor log.""" |
212 | 212 |
|
213 | | - def __init__(self,prog): |
| 213 | + def __init__(self,prog,trainData=None,testData=None): |
214 | 214 | self.prog = prog |
215 | 215 | self.db = self.prog.db |
| 216 | + self.trainData = trainData |
| 217 | + self.testData = testData |
216 | 218 |
|
217 | 219 | def help(self): |
218 | 220 | print "ti.list(foo): foo can be a compiled function, eg \"foo/io\", a predicate definition, eg" |
219 | 221 | print " \"foo/2\", or a database predicate, also specified as \"foo/2\"." |
220 | 222 | print "ti.list(): list everything." |
221 | 223 | print "ti.eval(\"functor/mode\",\"c\"): evaluate a function on a database constant c" |
222 | 224 | print "ti.debug(\"functor/mode\",\"c\"): debug the corresponding eval command" |
| 225 | + print "ti.debugDset(\"functor/mode\"[,test=True]): run debugger on a dataset" |
223 | 226 |
|
224 | 227 | def list(self,str=None): |
225 | 228 | if str==None: |
@@ -273,6 +276,15 @@ def debug(self,modeSpec,sym): |
273 | 276 | dset = dataset.Dataset({mode:X},{mode:self.db.zeros()}) |
274 | 277 | debug.Debugger(self.prog,mode,dset,gradient=False).mainloop() |
275 | 278 |
|
| 279 | + def debugDset(self,modeSpec,test=False): |
| 280 | + fullDataset = self.testData if test else self.trainData |
| 281 | + if fullDataset==None: |
| 282 | + print 'train/test dataset is not specified on command line?' |
| 283 | + else: |
| 284 | + mode = declare.asMode(modeSpec) |
| 285 | + dset = fullDataset.extractMode(mode) |
| 286 | + debug.Debugger(self.prog,mode,dset,gradient=True).mainloop() |
| 287 | + |
276 | 288 | # |
277 | 289 | # utilities for reading command lines |
278 | 290 | # |
@@ -367,7 +379,7 @@ def parseProgSpec(spec,db,proppr=False): |
367 | 379 | print "Tensorlog v%s (C) William W. Cohen and Carnegie Mellon University, 2016" % VERSION |
368 | 380 |
|
369 | 381 | optdict,args = parseCommandLine(sys.argv[1:]) |
370 | | - ti = Interp(optdict['prog']) |
| 382 | + ti = Interp(optdict['prog'],trainData=optdict.get('trainData'),testData=optdict.get('testData')) |
371 | 383 |
|
372 | 384 | try: |
373 | 385 | if sys.ps1: interactiveMode = True |
|
0 commit comments