#coding:utf-8 ''' Created on 2018年3月1日 @author: qiujiahao @email:[email protected] ''' import logging import conf import time import os from threading import Thread,Timer dir = conf.get_args().module_path start_log = False if not os.path.exists(dir+'/log'): os.makedirs(dir+'/log') def log(info,level='debug'): "获取当前时间" print(info,start_log)#此处再打印一下,方便我调试 if start_log==False: return date=time.strftime("%Y%m%d") filename=dir+'/log/'+date+'.txt' loc_time=time.strftime("%H:%M:%S") if level=='debug': logging.basicConfig(filename=filename,level=logging.DEBUG)
def __init__(self): self.args = get_args() self.graph = Graph('bolt://localhost:7687', user=self.args.neo4j_user, password=self.args.neo4j_password)
def __init__(self): self.args=get_args() self.data_process()
import sys sys.path.append("lib") sys.path.append('src') import conf import platformdep import mylogging VERSION = "0.3.3" # also in setup_script.iss args = conf.get_args() # configuration dictionary appName = "nameGUI" CONFFOLDER = args.datadir if args.datadir else platformdep.get_conf_dir(appName.lower()) LOGFILENAME = "logfile.txt" LOGFILENAMEPATH = CONFFOLDER + "/" + LOGFILENAME LOGLEVELCONSOLE = mylogging.DEBUG LOGLEVELFILE = mylogging.DEBUG NAMENEWDBFILENAME = "nameNewDb.txt" NAMENEWDBFILENAMEPATH = CONFFOLDER + "/" + NAMENEWDBFILENAME def get_my_logger(name): return mylogging.get_logger(name=name, levelConsole=LOGLEVELCONSOLE, filename=LOGFILENAMEPATH, levelFile=LOGLEVELFILE)
while True: input_word = input('请输入您的问题:') text = data.text2index(input_word) if use_cuda: seq2seq_model = Seq2Seq(input_dim, embedding_dim, hidden_dim, output_dim, use_cuda=use_cuda).cuda() else: seq2seq_model = Seq2Seq(input_dim, embedding_dim, hidden_dim, output_dim, use_cuda=use_cuda) seq2seq_model.load_state_dict(torch.load(args.module_path)) seq2seq_model.eval() #predict_indices = seq2seq_model.seq2seq_predict(text) #predict_result = data.index2text(predict_indices) #print(predict_result) predict_sample_indices = seq2seq_model.beamsearch(text) for predict_indices in predict_sample_indices: predict_result = data.index2text(predict_indices) print("".join(predict_result[:-1])) #rerank_by_bleu(input_word, results) if __name__=='__main__': args=get_args() data=data(args) data.data_split() args.vocab_size=data.vocab_size print('参数列表:{}'.format(args)) if args.mode=='train': start_train(args,data) else: start_test(args,data)
import sys sys.path.append("lib") sys.path.append('src') import conf import platformdep import mylogging VERSION = "0.3.3" # also in setup_script.iss args = conf.get_args() # configuration dictionary appName = "nameGUI" CONFFOLDER = args.datadir if args.datadir else platformdep.get_conf_dir( appName.lower()) LOGFILENAME = "logfile.txt" LOGFILENAMEPATH = CONFFOLDER + "/" + LOGFILENAME LOGLEVELCONSOLE = mylogging.DEBUG LOGLEVELFILE = mylogging.DEBUG NAMENEWDBFILENAME = "nameNewDb.txt" NAMENEWDBFILENAMEPATH = CONFFOLDER + "/" + NAMENEWDBFILENAME def get_my_logger(name): return mylogging.get_logger(name=name, levelConsole=LOGLEVELCONSOLE, filename=LOGFILENAMEPATH, levelFile=LOGLEVELFILE)
import conf from handwriting.training import train from handwriting.validation import validate if __name__ == "__main__": # Get conf parameters settings = conf.get_args() ################ # TRAINING ################ if settings.train_unconditional: train.train_unconditional(settings) if settings.train_conditional: train.train_conditional(settings) ################ # VALIDATION ################ if settings.validate_unconditional: validate.validate_unconditional(settings) if settings.validate_conditional: validate.validate_conditional(settings)