Ejemplo n.º 1
0
args.server_ip = ''
args.server_port = ''
args.output_mode = "classification"
args.save_model_steps = 2000
args.resume_epochs = 0
args.resume_steps = 0

# Important configurations
args.data_dir = 'dataset/preprocessed'
args.train_file = None
args.dev_file = 'friends_majority_result.json'
args.result_file = 'friends_all_result.json'
args.train_batch_size = 32
args.eval_batch_size = 32
args.do_train = False
args.do_eval = False
args.do_run = True
args.num_train_epochs = 1.0
args.max_seq_length = 256
args.processor = Others_OneSentence_Processor
args.output_dir = None
args.resume_dir = os.path.join(model_dir, 'friends_others/epoch_6')

args.learning_rate = 1e-5
args.seed = 69847

args.included_labels = 7

trainer = Trainer(args)
trainer.execute()
    print "Training started"

    for n in range(1, trainSetSize+1):
        filename = "train%d.tif" % n
        print filename
        trainer.train(trainAnno, container, filename)

    trainRef = trainer.record(container)

    ###############################################

    print "Dev set recognition started"

    devRef = trainer.openAnnoFile("annotations/dev.txt")


    rightNum = 0.0
    percentage = 0.0

    for n in range(1, devSetSize+1):
        filename = "dev%d.tif" % n
        print filename
        predClass, probability = trainer.execute(trainRef, filename)

        actualClass = int(devRef[filename])
        if actualClass == int(predClass):
            rightNum += 1
    percentage = (rightNum / (devSetSize+1)) * 100
    print "*** Recognition Result : ", str(percentage) + "% ***"