if int(''.join(curentday.split('-'))) == int(''.join("2019-10-27".split('-'))): curentday = datetime.datetime.strptime(curentday,"%Y-%m-%d") + datetime.timedelta(days=1) curentday = curentday.strftime("%Y-%m-%d") continue try: iiter =0 #从flaskapp log日志中,.1 .2 两个文件,提取出 两个 txt applog = os.path.join(PATH,logfile.format(curentday)) viewclickfile = handle_log.log(applog, curentday) #从两个TXT 提取 csv train_base = handle_train.generate_train_base(curentday,viewclickfile) #train_base = os.path.join(PATH,"train_base/train_base--2019-09-01.csv") # 结合 mysql数据中 储存的数据,出 训练数据 train_data = feature.get_data_with_pandas(train_base, batch_size) lr = 0.001 loss_sum = 0.0 accuracy_sum = 0.0 break_cnt = 1 flag = True #一天就93个数据吗,每次取一个batch for i in range(epoches): for data_pre in train_data: data_ = prepare_data(data_pre) data_["lr_ph"] = lr
import handle_log begin = time.time() handle_log.log(file, day) print(day, "handle log costs: ", time.time() - begin) import handle_train begin = time.time() train_base = handle_train.generate_train_base(day) print(day, "handle train_base costs: ", time.time() - begin) import feature begin = time.time() train_data = feature.get_data_with_pandas(train_base, 128) print(day, "handle feature costs: ", time.time() - begin) import model begin = time.time() mol = model.SimpleModel() with tf.Session(graph=mol.graph) as sess: sess.run(tf.global_variables_initializer()) sess.run(tf.local_variables_initializer()) iiter = utils.get_max_model_num(MODLE_PATH) if iiter != -1: mol.restore(sess, os.path.join(MODLE_PATH, "ckpt_") + str(iiter)) if iiter == -1: