Example #1
0
 def __init__(self, model_path):
     self.voca_size = 30522
     self.hp = hyperparams.HPFAD()
     self.model_dir = cpath.model_path
     self.task = transformer_next_sent(self.hp, 2, self.voca_size, False)
     self.sess = init_session()
     self.sess.run(tf.global_variables_initializer())
     self.load_model_white(model_path)
     self.batch_size = 64
Example #2
0
 def __init__(self, model_path, num_classes):
     self.voca_size = 30522
     load_names = ['bert', "output_bias", "output_weights"]
     self.hp = hyperparams.HPFAD()
     self.model_dir = cpath.model_path
     self.task = transformer_logit(self.hp, num_classes, self.voca_size,
                                   False)
     self.sess = init_session()
     self.sess.run(tf.global_variables_initializer())
     self.load_model_white(model_path, load_names)
     self.batch_size = 64
Example #3
0
def train_adhoc_fad():
    hp = hyperparams.HPFAD()
    hp.batch_size = 16
    e = Experiment(hp)

    e_config = ExperimentConfig()
    e_config.name = "Adhoc_{}".format("FAD")
    e_config.num_epoch = 4
    e_config.save_interval = 10 * 60  # 60 minutes
    e_config.load_names = ['bert']  #, 'reg_dense']
    vocab_size = 30522

    data_loader = data_sampler.DataLoaderFromFile(hp.batch_size, vocab_size)
    load_id = ("uncased_L-12_H-768_A-12", 'bert_model.ckpt')
    #load_id = ("Adhoc_I2", 'model-290')
    e.train_adhoc2(e_config, data_loader, load_id)
Example #4
0
def predict_adhoc512():
    hp = hyperparams.HPFAD()
    hp.batch_size = 16
    e = Experiment(hp)

    e_config = ExperimentConfig()
    e_config.name = "Adhoc_J_{}".format("512")
    e_config.num_epoch = 4
    e_config.save_interval = 10 * 60  # 60 minutes
    e_config.load_names = ['bert', 'reg_dense']
    vocab_size = 30522

    payload_path = os.path.join(cpath.data_path, "robust_payload",
                                "enc_payload_512.pickle")
    task_idx = int(sys.argv[2])
    print(task_idx)
    load_id = ("Adhoc_J_512", 'model-6180')
    e.predict_robust(e_config, vocab_size, load_id, payload_path, task_idx)