time.strftime('%Y-%m-%d %H-%M-%S', time.localtime(time.time()))) else: pass print("\n测试模式...") # timestamp = input("请输入要restore的模型生成时间戳,例如2018-12-12 19-58-25:") timestamp = "2018-12-19 17-39-12" # timestamp = "2018-12-19 17-03-59" print("\n当前加载的模型是: ", timestamp, '\n') args.is_training = False args.model_path = os.path.join('.', "model", timestamp + "/") # args.model_path = os.path.join('.', "model", 'test' + "/") if not os.path.exists(args.model_path): os.makedirs(args.model_path) if args.is_training: model = Graph(args, cn_words_embedding, en_words_embedding, cn_word2id_dict, en_word2id_dict, en_id2word_dict) model.build_graph() model.train(cn_train_data, en_train_data) else: args.model_path = tf.train.latest_checkpoint(args.model_path) model = Graph(args, cn_words_embedding, en_words_embedding, cn_word2id_dict, en_word2id_dict, en_id2word_dict) model.build_graph() print("=============================") model.test(cn_dev_data, en_dev_data)
# Config default value cfg = config.cfg # Training files name cfg.queue.filename = [ os.path.join(os.path.dirname(os.path.basename(__file__)), "examples", "train{}.tfrecords").format(index) for index in range(args.train_first_file, args.train_first_file + args.train_set_size // cfg.queue.nb_examples_per_file)] print(cfg.queue.filename) # Whether we create a validation set cfg.queue.is_val_set = args.val_set # Whether to train with adversarial cost cfg.gan.train_adversarial = args.train_adversarial # Size of a batch cfg.train.batch_size = args.batch_size # Build model and train or fill images b = Graph(cfg) b.build() if args.train: b.train() else: # TODO: add a queue for validation set (change args parameter in consequences) b.fill_image(20)