transform

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

commit b4f7c88d434c6827c9505b734148d890e1b7e772
parent 4ccc1084a6b4cff5eed0ab7b004a3eb012153e2a
Author: Étienne Simon <esimon@esimon.eu>
Date:   Fri, 18 Apr 2014 15:22:39 +0200

Add datalog

Diffstat:
Mmain.py | 1+
Mmodel.py | 1+
Mutils/log.py | 6++++++
3 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/main.py b/main.py @@ -21,6 +21,7 @@ if __name__ == '__main__': for k, v in hyperparameters.iteritems(): if isinstance(v, basestring) and v.startswith('python:'): hyperparameters[k] = eval(v[7:]) + datalog_filepath = hyperparameters['datalog filepath'] data = Dataset(data) if model_path is None: diff --git a/model.py b/model.py @@ -164,6 +164,7 @@ class Model(object): log('Validation epoch {:<5}'.format(epoch)) (valid_mean, valid_top10) = self.error('valid') log(' valid mean: {0:<15} valid top10: {1:<15}'.format(valid_mean, valid_top10)) + datalog(epoch, valid_mean, valid_top10) if not hasattr(self, 'best_mean') or valid_mean < self.best_mean: self.best_mean = valid_mean log('(best so far') diff --git a/utils/log.py b/utils/log.py @@ -4,3 +4,9 @@ import sys def log(message): print(message, end='') sys.stdout.flush() + +datalog_filepath=None + +def datalog(*data) + with open(filepath, 'a') as file: + file.write('\t'.join(data)+'\n')