Пример #1
0
oracle_train_all_errors.append(oracle_err)
#oracle_mtl_errors.append(oracle_err)
print "Initial Error OracleMTL---Train All: %f" % oracle_err

svm_train_all.train_all_fs()
svm_train_all.train_ws()
svm_err = lg.seg_model_error_01(svm_train_all,test_xs,test_ys,test_ss)
print 'Initial Error SVM_mtl---Train All: ', svm_err
svm_train_all_errors = [svm_err]

"""
## strategy: retrain-new
oracle_retrain_new_errors = []
oracle_retrain_new = lg.LgSegmentModel(xs,ys,ss,'train-all',k)
svm_retrain_new = lg.UserDefineModel(xs,ys,dy,ss,'train-all') # using the default value 
test_xs,test_ys,test_ss = digits.generate_additional_data (tasks, oracle_retrain_new, svm_retrain_new,3)
for j in range(train_iter):
    oracle_retrain_new.train_all_fs()
    oracle_retrain_new.train_ws()
oracle_retrain_new.strategy = 'retrain-new'    

svm_retrain_new.train_all_fs()
svm_retrain_new.train_ws()
svm_retrain_new_errors = []
svm_retrain_new.strategy = 'retrain-new'
oracle_err = lg.seg_model_error_01(oracle_retrain_new, test_xs, test_ys, test_ss, num=20)
oracle_retrain_new_errors.append(oracle_err)
svm_err = lg.seg_model_error_01(svm_retrain_new,test_xs,test_ys,test_ss)
svm_retrain_new_errors.append(svm_err)
print "Initial Error OracleMTL---Train All: %f" % oracle_err
print 'Initial Error SVM_mtl---Train All: ', svm_err
Пример #2
0
svm_mtl1.train_ws()
svm_err = lg.seg_model_error_01(svm_mtl1,test_xs,test_ys,test_ts)
print 'Initial Error SVM_mtl-l1 ', svm_err
svm_feature_errors1 = []

d_mtl = lg.NonSharingModel(xs,ys,ss)
d_mtl.train_ws()
d_err = lg.seg_model_error_01(d_mtl,test_xs,test_ys,test_ts)
print 'Initial Error non-sharing model ', d_err
d_feature_errors = []
print 

####### Cold-Start Experiment #################
# number of points range from 2-30, step = 1
task = digits.create_mtl_datasets(Z,train_y,nTasks=100,taskSize=30,testSize=40)
test_xs,test_ys,test_ts = digits.generate_additional_data(task,oracle_mtl, svm_mtl, svm_mtl1, d_mtl,0)


iters = range(2,30)
for i in iters:
    print 'cold-start: # of points trained: ', i
    
    oracle_mtl.train_ws(i)
    oracle_err = lg.seg_model_error_01(oracle_mtl, test_xs, test_ys, test_ts, num=20)
    oracle_mtl_errors.append(oracle_err)
    print 'Testing Error of oracle model is ', oracle_err
        
    svm_mtl.train_ws(i)
    svm_err = lg.seg_model_error_01(svm_mtl,test_xs,test_ys,test_ts)
    svm_feature_errors.append(svm_err)
    print 'Testing Error of svm model --l2 is ', svm_err