Skip to content

Commit

Permalink
Merge pull request #112 from Sujit-O/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
louisccc authored Mar 3, 2020
2 parents 65fc4da + 5835297 commit 337a5e6
Show file tree
Hide file tree
Showing 7 changed files with 417 additions and 376 deletions.
4 changes: 2 additions & 2 deletions pykg2vec/config/hyperparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self):
'ntn' : {'learning_rate': 0.01,'L1_flag': True,'ent_hidden_size':64,'rel_hidden_size':32,'batch_size': 128,'epochs': 1000,'margin': 1.0,'optimizer':'adam','sampling':"uniform",'neg_rate':1}, # problematic
'slm' : {'learning_rate': 0.01,'L1_flag': True,'ent_hidden_size':64,'rel_hidden_size':32,'batch_size': 128,'epochs': 1000,'margin': 1.0,'optimizer':'adam','sampling':"uniform",'neg_rate':1},
'kg2e' : {'learning_rate': 0.01,'L1_flag': True,'hidden_size':50,'batch_size':1440,'epochs':1000,'margin': 4.0,'optimizer': 'sgd','sampling':"uniform",'distance_measure': "kl_divergence",'cmax': 0.05,'cmin': 5.00,'neg_rate': 1},
'complex' : {'learning_rate': 0.5,'hidden_size':200,'batch_size':5000,'epochs':1000,'optimizer':'adagrad','sampling':"uniform",'neg_rate':1,'lmbda':0.0001},
'complex' : {'learning_rate': 0.5,'hidden_size':100,'batch_size':5000,'epochs':1000,'optimizer':'adagrad','sampling':"uniform",'neg_rate':10,'lmbda':0.0001},
'distmult': {'learning_rate': 0.1,'hidden_size':100,'batch_size':50000,'epochs':1000,'data':'Freebase15k','optimizer':'adagrad','sampling':"uniform",'neg_rate':1,'lmbda':0.0001},

}
Expand Down Expand Up @@ -108,7 +108,7 @@ def __init__(self):
'L1_flag': hp.choice('L1_flag', [True, False]),
'hidden_size': scope.int(hp.qloguniform('hidden_size', np.log(8), np.log(512),1)),
'batch_size': scope.int(hp.qloguniform('batch_size', np.log(8), np.log(4096),1)),
'margin': hp.uniform('margin', 0.0, 2.0),
'margin': hp.uniform('margin', 0.0, 10.0),
'optimizer': hp.choice('optimizer', ["adam", "sgd", 'rms']),
'epochs': hp.choice('epochs', [500]) # always choose 10 training epochs.
}
Expand Down
5 changes: 2 additions & 3 deletions pykg2vec/core/Complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ def def_loss(self):

regul_term = tf.reduce_sum(pos_h_e_real**2 + pos_h_e_img**2) + tf.reduce_sum(pos_r_e_real**2 + pos_r_e_img**2) + tf.reduce_sum(pos_t_e_real**2 + pos_t_e_img**2) + \
tf.reduce_sum(neg_h_e_real**2 + neg_h_e_img**2) + tf.reduce_sum(neg_r_e_real**2 + neg_r_e_img**2) + tf.reduce_sum(neg_t_e_real**2 + neg_t_e_img**2)
loss_term = tf.reduce_sum(tf.concat([tf.nn.softplus(-1*score_pos), tf.nn.softplus(score_neg)], axis=0))

self.loss = loss_term + self.config.lmbda*regul_term

self.loss = self.pointwise_logistic_loss(score_pos, score_neg) + self.config.lmbda*regul_term

def test_batch(self):
"""Function that performs batch testing for the algorithm.
Expand Down
Loading

0 comments on commit 337a5e6

Please sign in to comment.