transform

old TransE-like models
git clone https://esimon.eu/repos/transform.git
Log | Files | Refs | README

commit a6ea206decf38474e3c970077f96fabe40811829
parent 9aa890972b341519afb1339f636d968944f86ecf
Author: Étienne Simon <esimon@esimon.eu>
Date:   Wed, 16 Apr 2014 14:05:25 +0200

Clean the code

Diffstat:
Mmodel.py | 9+++------
Rutils/construct_dummy_dataset.py -> utils/build dummy dataset.py | 0
2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/model.py b/model.py @@ -33,7 +33,6 @@ class Model(object): hyperparameters -- hyperparameters dictionary tag -- name of the embeddings for parameter declaration """ - print >>sys.stderr, '# Initialising model "{0}"'.format(tag) self = cls() @@ -55,11 +54,9 @@ class Model(object): dataset -- dataset on which the model will be trained and tested hyperparameters -- hyperparameters dictionary """ - print >>sys.stderr, '# Loading model from "{0}"'.format(filepath) self = cls() - with open(filepath, 'rb') as file: self.embeddings = cPickle.load(file) self.relations = cPickle.load(file) @@ -128,9 +125,9 @@ class Model(object): batch_result = self.scoring_function(relation, left, entities) scores = numpy.array(batch_result, dtype=theano.config.floatX) if scores is None else numpy.concatenate((scores, batch_result), axis=1) rank = 1+numpy.where(numpy.argsort(scores)==right.indices[0])[1] # FIXME ugly - mean = mean + rank - count = count + 1 - top10 = top10 + (rank<=10) + mean += rank + count += 1 + top10 += (rank<=10) mean = float(mean) / count top10 = float(top10) / count return (mean, top10) diff --git a/utils/construct_dummy_dataset.py b/utils/build dummy dataset.py