summaryrefslogtreecommitdiffstats
path: root/tryprune.py
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-07-27 19:39:24 +0800
committerPeng Wu <alexepico@gmail.com>2011-07-27 19:39:24 +0800
commitc8c090a77e0ab448c8b65abf40d035f51f9b414d (patch)
tree1289390bf9754f8cd1921ee05441df109ba2873a /tryprune.py
parentcd94f84088b4a60f19a6035a0d3a475be1550157 (diff)
downloadtrainer-c8c090a77e0ab448c8b65abf40d035f51f9b414d.tar.gz
trainer-c8c090a77e0ab448c8b65abf40d035f51f9b414d.tar.xz
trainer-c8c090a77e0ab448c8b65abf40d035f51f9b414d.zip
fixes tryprune.py
Diffstat (limited to 'tryprune.py')
-rwxr-xr-xtryprune.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/tryprune.py b/tryprune.py
index e9f6ba0..c472d3c 100755
--- a/tryprune.py
+++ b/tryprune.py
@@ -52,13 +52,10 @@ def exportModel(modelfile, textmodel):
def convertModel(kmm_model, inter_model):
#begin processing
- cmdline = ['./k_mixture_model_to_interpolation']
+ cmdline = './k_mixture_model_to_interpolation <"' + kmm_model + '"'
- subprocess = Popen(cmdline, shell=False, stdin=PIPE, \
+ subprocess = Popen(cmdline, shell=True, \
stdout=PIPE, close_fds=True)
- with open(kmm_model, 'rb') as f:
- subprocess.stdin.writelines(f.readlines())
- f.close()
with open(inter_model, 'wb') as f:
f.writelines(subprocess.stdout.readlines())
@@ -122,7 +119,7 @@ def mergeSomeModels(mergedmodel, sortedindexname, mergenum):
def pruneModel(prunedmodel, k, CDF):
#begin processing
cmdline = ['./prune_k_mixture_model', \
- '-k', k, '--CDF', CDF,
+ '-k', str(k), '--CDF', str(CDF),
prunedmodel]
subprocess = Popen(cmdline, shell=False, close_fds=True)
@@ -160,7 +157,7 @@ if __name__ == '__main__':
print(args)
tryname = 'try' + args.tryname
- trydir = os.path.join(config.getFinalDir(), tryname)
+ trydir = os.path.join(config.getFinalModelDir(), tryname)
#check try<name> directory
if os.access(trydir, os.F_OK):
@@ -208,7 +205,7 @@ if __name__ == '__main__':
cwdstatus['PruneModelSize'] = modelsize
utils.store_status(cwdstatuspath, cwdstatus)
- print('final model size:' + modelsize)
+ print('final model size:', modelsize)
#sign status epoch
utils.sign_epoch(cwdstatus, 'Prune')