commit a6f3d27b7ab6409c39f4c5c2f6a6db351c2851aa parent 92edccd19c7fe9e4e0e0f36bf2fd04944d2ea272 Author: Étienne Simon <esimon@esimon.eu> Date: Tue, 10 Jun 2014 15:41:09 +0200 Add script to test for NaN in models parameters Diffstat:
A | utils/test NaN.py | | | 19 | +++++++++++++++++++ |
1 file changed, 19 insertions(+), 0 deletions(-)
diff --git a/utils/test NaN.py b/utils/test NaN.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python2 + +from __future__ import print_function +import sys +import numpy + +from model import * +from relations import * + +if __name__ == '__main__': + if len(sys.argv)<2: + print('Usage: {0} model'.format(sys.argv[0]), file=sys.stderr) + sys.exit(1) + model = Model(None, {'model name': 'test'}, sys.argv[1]) + for parameter in model.embeddings.parameters + model.relations.parameters: + if numpy.isnan(parameter.get_value().sum()): + print('NaN found') + sys.exit(0) + print('NaN not found')