示例#1
0
            # why are there missing GO terms still ??? maybe these GO terms were not used in "axiom A is_a B" in Onto2vec ??
            # set 0 for GO terms not found .... ??? this is the only way. or we have to update the entire matrix
            if go in pretrained_weight:
                temp[index] = pretrained_weight[go]
        ## now we get word dim and so forth
        pretrained_weight = temp  ## override

    ## keep these
    other_params['num_of_word'] = pretrained_weight.shape[0]
    other_params['word_vec_dim'] = pretrained_weight.shape[1]
    other_params['pretrained_weight'] = pretrained_weight

# cosine model
# **** in using cosine model, we are not using the training sample A->B then B not-> A
cosine_loss = encoder_model.cosine_distance_loss(
    args.def_emb_dim, args.def_emb_dim,
    args)  ## remember to turn on reduce flag ???

# entailment model
# ent_model = entailment_model.entailment_model (num_labels,args.gcnn_dim,args.def_emb_dim,weight=torch.FloatTensor([1.5,.75])) # torch.FloatTensor([1.5,.75])

metric_pass_to_joint_model = {'entailment': None, 'cosine': cosine_loss}

## NEED TO MAKE THE BERT MODEL

# use BERT tokenizer
bert_config = BertConfig(os.path.join(args.bert_model, "bert_config.json"))

other = {'metric_option': args.metric_option}
bert_lm_sentence = BertForPreTraining.from_pretrained(args.bert_model)
bert_lm_ent_model = BERT_encoder_model.encoder_model(
示例#2
0
                go = re.sub("GO:", "", go)
            # enforce strict "GO:xyz" but onto2vec doesn't have this
            # why are there missing GO terms still ??? maybe these GO terms were not used in "axiom A is_a B" in Onto2vec ??
            # set 0 for GO terms not found .... ??? this is the only way. or we have to update the entire matrix
            if go in pretrained_weight:
                temp[index] = pretrained_weight[go]

        ## now we get word dim and so forth
        pretrained_weight = temp  ## override
        other_params['num_of_word'] = pretrained_weight.shape[0]
        other_params['word_vec_dim'] = pretrained_weight.shape[1]
        other_params['pretrained_weight'] = pretrained_weight

# cosine model
# **** in using cosine model, we are not using the training sample A->B then B not-> A
cosine_loss = encoder_model.cosine_distance_loss(args.gcnn_dim, args.gcnn_dim,
                                                 args)

# entailment model
# ent_model = entailment_model.entailment_model (num_labels,args.gcnn_dim,args.def_emb_dim,weight=torch.FloatTensor([1.5,.75])) # torch.FloatTensor([1.5,.75])

metric_pass_to_joint_model = {'entailment': None, 'cosine': cosine_loss}

## make GCN model

if args.w2v_emb is None:
    model = encoder_model.encoder_model(
        args, metric_pass_to_joint_model[args.metric_option], **other_params)

else:

    print(other_params)