Exemple #1
0
cluster_point = 6

for hidden_num in range(64, 320, 32):
    for magweight in range(6, 20, 2):
        magweight = magweight / 10.

        # drop_pro = float(drop)/10.
        net_size = [chardim, hidden_num * 2, hidden_num, len(tags)]
        #net_size = [chardim, hidden_num*2, hidden_num,len(tags)]
        print "model  initialization ............network size  " + str(
            net_size)
        model = semimodel(len(tags),
                          em_num,
                          net_size,
                          magweight,
                          sam_cnum,
                          layerid,
                          hinge,
                          lrate=0.02,
                          opt="adaGrad",
                          embeddic={"dic_1": embedding})
        print "model training preparing.........................."
        model.train_ready(True, 'joint-train')
        model.evaluate_ready()
        print "model training ready ............................."
        epoch = 1
        modelstr = storedir + "/hid_" + str(hidden_num) + "_magweight_" + str(
            magweight)
        if os.path.exists(modelstr):
            shutil.rmtree(modelstr)
        os.mkdir(modelstr)
        #os.mknod(modelstr+"/trainscore")
Exemple #2
0
#list1 = range(100,110,10)#tune
#list2 = [0]*len(list1)#tune
#list1 = [100]*10
#list2 = range(5,55,5)
#for hidden_num, semiweight in zip(list1,list2):
list1 = [120]
list2 = [90]
for hidden_num1, hidden_num2 in zip(list1,list2):
        semiweight = 0
        #semiweight = semiweight/10.
        
	
	#net_size = [dim, hidden_num1*2, len(tags)]
	net_size = [dim, hidden_num1*2,hidden_num2*2, len(tags)]
        print "model  initialization ..............network size  "+str(net_size)
        model = semimodel(len(tags),em_num, net_size,dropout = dropout_pro, lrate=0.1, wdecay = 0.0, opt = "adaGrad",fix_emb = True, embeddic = embeddic, premodel = loadedmodel)


        print "model training preparing.........................."
        model.train_ready()
        model.evaluate_ready()
        print "model training ready ............................."
        modelstr = storedir+"/hid1_"+str(hidden_num1)+"_hid2_"+str(hidden_num2)
        if os.path.exists(modelstr):
            shutil.rmtree(modelstr)
        os.mkdir(modelstr)
        os.mknod(modelstr+"/trainscore")
        os.mknod(modelstr+"/devscore")


        print "start fine-tuning   .........."
Exemple #3
0
    print "model initialization ..............model type  " + str(mtype)
    print "model  initialization ..............network size  " + str(net_size)
    print "model  initialization .............pre-training  epoch  " + str(
        pretime)

    #model = semimodel(len(tags),em_num, net_size,typenum = labelnum, model_type = mtype, wordnum = wordnum, LMweight = LMweight, padding_id = outpadding_id,layerid = layerid,
    #dropout = dropout_pro, lrate=0.03, wdecay = 0., opt = "adaGrad",fix_emb = False, embeddic = {"dic_1": embedding})

    model = semimodel(len(tags),
                      em_num,
                      net_size,
                      typenum=labelnum,
                      model_type=mtype,
                      wordnum=wordnum,
                      LMweight=LMweight,
                      padding_id=outpadding_id,
                      layerid=layerid,
                      dropout=dropout_pro,
                      lrate=0.02,
                      wdecay=0.,
                      opt="adaGrad",
                      fix_emb=False,
                      embeddic=embeddic,
                      premodel=premodel)

    print "model training preparing.........................."
    model.train_ready()
    model.evaluate_ready()
    model.unsup_evaluate_ready()
    print "model training ready ............................."
    modelstr = storedir + "/hid1_" + str(hidden_num1) + "_hid2_" + str(
        hidden_num2)