def test_fb(): cvsm = CompositionalVectorAlgorithm("freebase", "data/fb15k237/cvsm_entity", entity_type2vec_filename=None, pooling_method="sat", attention_method="sat", early_stopping_metric="map") cvsm.train_and_test()
def test_wn(): cvsm = CompositionalVectorAlgorithm( "wordnet", experiment_dir="data/wn18rr/cvsm_entity", entity_type2vec_filename="data/wn18rr/entity_type2vec.pkl", pooling_method="sat", attention_method="sat", early_stopping_metric="map") cvsm.train_and_test()
process_paths( input_dir=os.path.join(CVSM_RET_DIR, "data/data_input"), output_dir=os.path.join(CVSM_RET_DIR, "data/data_output"), vocab_dir=os.path.join(CVSM_RET_DIR, "data/vocab"), isOnlyRelation=False, getOnlyRelation=False, MAX_POSSIBLE_LENGTH_PATH= 8, # the max number of relations in a path + 1 NUM_ENTITY_TYPES_SLOTS= 15, # the number of types + 1 (the reason we +1 is to create a meaningless type for all entities) pre_padding=True) # 5. Run the model # use $tensorboard --logdir runs to see the training progress if run_step == 5: cvsm = CompositionalVectorAlgorithm("wordnet", CVSM_RET_DIR, ENTITY_TYPE2VEC_FILENAME) # Not using pretrained word embeddings decreases performance # cvsm = CompositionalVectorAlgorithm("wordnet", CVSM_RET_DIR, None) cvsm.train_and_test() # Uncomment if need to train only one relation # cvsm.train("/home/weiyu/Research/ChainsOfReasoningWithAbstractEntities/data/wn18rr/cvsm_entity/data/data_output/member_of_domain_region") if run_step == 6: cvsm = CompositionalVectorAlgorithm( "wordnet", CVSM_RET_DIR, ENTITY_TYPE2VEC_FILENAME, pooling_method="sat",
from main.playground.model2.CompositionalVectorAlgorithm import CompositionalVectorAlgorithm if __name__ == "__main__": # 1. uncomment this part to train and test all relations for FB15k-237 cvsm = CompositionalVectorAlgorithm( experiment_dir="data/freebase15k237/cvsm_entity", entity_type2vec_filename=None) cvsm.train_and_test() # 2. uncomment this part to train and test all relations for WN18RR #cvsm = CompositionalVectorAlgorithm(experiment_dir="data/wordnet18rr/cvsm_entity", # entity_type2vec_filename="data/wordnet18rr/entity_type2vec.pkl") #cvsm.train_and_test()
vocab_dir= "/home/weiyu/Research/ChainsOfReasoningWithAbstractEntities/data/fb15k237/cvsm_entity/data/vocab", isOnlyRelation=False, getOnlyRelation=False, MAX_POSSIBLE_LENGTH_PATH= 8, # the max number of relations in a path + 1 NUM_ENTITY_TYPES_SLOTS= 7, # the number of types + 1 (the reason we +1 is to create a meaningless type for all entities) pre_padding=True) # 13. Run the model # use $tensorboard --logdir runs to see the training progress if run_step == 14: cvsm = CompositionalVectorAlgorithm("freebase", CVSM_RET_DIR, None, attention_method="sat", early_stopping_metric="map") # cvsm.train_and_test() #cvsm = CompositionalVectorAlgorithm(CVSM_RET_DIR, None, attention_method="specific", early_stopping_metric="map") #cvsm.train_and_test() #cvsm = CompositionalVectorAlgorithm(CVSM_RET_DIR, None, attention_method="abstract", early_stopping_metric="map") #cvsm.train_and_test() # Uncomment if need to train only one relation # cvsm.train("/home/weiyu/Research/ChainsOfReasoningWithAbstractEntities/data/fb15k237/cvsm_entity/data/data_output/|food|food|nutrients.|food|nutrition_fact|nutrient") if run_step == 15: cvsm = CompositionalVectorAlgorithm("freebase",