transform

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

commit 671882ec4d665f412280a6ec4a696b1e889588d1
parent 5c7737033228073cff1311fc3cde11725d7df1f0
Author: Étienne Simon <esimon@esimon.eu>
Date:   Fri, 18 Apr 2014 15:37:40 +0200

Parameterise main

Diffstat:
Mdataset.py | 2+-
Mmain.py | 8++++----
Mmodel.py | 2+-
Mrelations/__init__.py | 14++++++++++++++
4 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/dataset.py b/dataset.py @@ -1,6 +1,6 @@ #!/usr/bin/env python2 -from utils.log import log +from utils.log import * import scipy import numpy import theano diff --git a/main.py b/main.py @@ -1,16 +1,16 @@ #!/usr/bin/env python2 -from utils.log import log +from utils.log import * import sys import json from dataset import * from model import * -from relations.translations import * +from relations import * if __name__ == '__main__': if len(sys.argv)<3: - log('Usage: {0} data parameters [model]\n'.format(sys.argv[0]), file=sys.stderr) + print('Usage: {0} data parameters [model]\n'.format(sys.argv[0]), file=sys.stderr) sys.exit(1) data = sys.argv[1] config = sys.argv[2] @@ -25,7 +25,7 @@ if __name__ == '__main__': data = Dataset(data) if model_path is None: - model = Model.initialise(Translations, data, hyperparameters, 'TransE') + model = Model.initialise(hyperparameters['relations'], data, hyperparameters, 'TransE') else: model = Model.load(model_path, data, hyperparameters, 'TransE') model.train() diff --git a/model.py b/model.py @@ -1,6 +1,6 @@ #!/usr/bin/env python2 -from utils.log import log +from utils.log import * import cPickle import numpy import scipy diff --git a/relations/__init__.py b/relations/__init__.py @@ -0,0 +1,14 @@ +__all__ = [] + +import pkgutil +import inspect + +for loader, name, is_pkg in pkgutil.walk_packages(__path__): + module = loader.find_module(name).load_module(name) + + for name, value in inspect.getmembers(module): + if name.startswith('__'): + continue + + globals()[name] = value + __all__.append(name)