Exemple #1
0
    
    seen = 0
    totloss = 0
    totacc = 0
    apseen = 0
    totobjAP = 0
    totactAP = 0
    progbar = Progbar(target=len(indtrain))
    for i in range(len(indtrain)):
        # pdb.set_trace()
        # if not os.path.isfile(os.path.join(jsonpath,str(indtrain[i])+'.json')):
            # print('no file exist')
            # continue
        start = time.time()
        # print('get DB from json files')
        X_train, act_label, obj_label = readjson.getDB(ind=indtrain[i])
        # y_train = readjson.to_categorical_dual(y_train,10)
        endread = time.time()
        
        if isGraph:
            model.fit({'input1':X_train,'actout':act_label,'objout':obj_label},batch_size=128,\
                        nb_epoch=1,shuffle=False,verbose=0,callbacks=[MPLC])
        else:    
        # print('model fit')
            model.fit(X_train,act_label,batch_size=128,nb_epoch=1,show_accuracy=True,shuffle=False,\
                      verbose=0,callbacks=[MPLC])

        endfit = time.time()

        # pdb.set_trace()
        
totlen = len(indtrain)
for i in range(totlen):
    if i%50 == 0:
        print('cur ' +str(i))
    if i%1000 == 0:
        f = open(savefold+str(i)+'.pkl.gz','w')
        tofile.append(trainall)
        tofile.append(actall)
        tofile.append(objall)
        cPickle.dump(tofile,f)
        f.close()
        tofile = []
        trainall = []
        actall = []
        objall = []
    X_train, act_label, obj_label = readjson.getDB(jsonpath=jsonpath,ind=indtrain[i])
    # pdb.set_trace()
    X_train = normalized(X_train)
    trainall.append(X_train)
    # at here, all labels are same. should it be appended?
    actall.append(act_label)
    objall.append(obj_label)

# f = open('vals.pkl.gz','w')
f = open(savefold+str(totlen)+'.pkl.gz','w')
tofile.append(trainall)
tofile.append(actall)
tofile.append(objall)
cPickle.dump(tofile,f)
f.close()
tofile = []