-
Notifications
You must be signed in to change notification settings - Fork 1
/
train.py
43 lines (35 loc) · 962 Bytes
/
train.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from imageImplementation import CacheObj
from imageImplementation import CommonApp
import ExampleLoader
import LSSVM
import Performance
import utils
import UserInput
import SPLSelector
import sys
def main():
try:
params = UserInput.getUserInput('train')
ExampleLoader.loadExamples(params)
CommonApp.setExampleCosts(params)
w = None
if params.initialModelFile:
w = CacheObj.loadObject(params.initialModelFile)
else:
w = CommonApp.PsiObject(params,False)
globalSPLVars = SPLSelector.SPLVar()
if params.splParams.splMode != 'CCCP':
SPLSelector.setupSPL(params)
w = LSSVM.optimize(w, globalSPLVars, params)
CacheObj.cacheObject(params.modelFile,w)
Performance.printStrongAndWeakTrainError(params, w)
except Exception, e :
import traceback
traceback.print_exc(file=sys.stdout)
finally:
if params.processes is not None:
for p in params.processes:
p.terminate()
sys.exit(1)
if __name__== "__main__":
main()