jbjorne / TEES

Turku Event Extraction System
147 stars 44 forks source link

CNN unicode error #32

Open abrayne opened 5 years ago

abrayne commented 5 years ago

Hi,

I'm working from TEES-development and the SVM works well for out of the box classification, but the CNN is throwing an error. I am running the example command from the wiki: python classify.py -m /Users/.../TEES-development/GE09-single.zip -i GE09-devel -o OUTCNN09 and this is the last portion of the output and traceback:

Vectorizing features: [u'POS', u'named_entities', u'path0', u'path1', u'path2', u'path3', u'positions', u'words'] POS (25721, 41) [ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 4 2 5 6 7 8 9 2 2 3 4 2 3 4 10 3 6 2 2] namedentities (25721, 41) [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 2 2 3 2 2 2 2 2 3 2 2] path0 (25721, 41) [ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 358 359 7 7 359 9 359 9 359 2 2 359 2 2 359 2 2 359 2 2 2] path1 (25721, 41) [ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 358 359 5 360 359 360 359 11 359 360 13 359 15 15 359 15 15 359 15 15 15] path2 (25721, 41) [ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 358 359 360 360 359 360 359 360 359 360 360 359 5 360 359 15 15 359 21 21 21] path3 (25721, 41) [ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 358 359 360 360 359 360 359 360 359 360 360 359 360 360 359 5 360 359 17 19 360] positions (25721, 41) [ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 22 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] words (25721, 41) [ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 13 16 17 18 19 20 21] Caching model "/Users/.../TEES-development/GE09-single.zip" member "entity-models.json" to "/var/folders/fr/bjgbbzm5475410z74rnk165r0000gn/T/tmp43ju9C/entity-models.json" Predicting with model 1 entity-model-15.hdf5 Caching model "/Users/.../TEES-development/GE09-single.zip" member "entity-model-15.hdf5" to "/var/folders/fr/bjgbbzm5475410z74rnk165r0000gn/T/tmp43ju9C/entity-model-15.hdf5" Traceback (most recent call last): File "classify.py", line 163, in preprocessorParams=options.preprocessorParams, bioNLPSTParams=options.bioNLPSTParams) File "classify.py", line 79, in classify detector.classify(classifyInput, model, output, goldData=goldInput, fromStep=detectorSteps["CLASSIFY"], omitSteps=omitDetectorSteps["CLASSIFY"], workDir=workDir) File "/Users/.../TEES-development/Detectors/KerasEventDetector.py", line 267, in classify EventDetector.classify(self, data, model, output, parse=parse, task=task, goldData=goldData, fromStep=fromStep, toStep=toStep, omitSteps=omitSteps, workDir=workDir) File "/Users/.../TEES-development/Detectors/EventDetector.py", line 342, in classify xml = self.triggerDetector.classifyToXML(self.classifyData, self.model, None, workOutputTag, goldData=goldData, parse=self.parse, recallAdjust=float(self.getStr("recallAdjustParameter", self.model))) File "/Users/.../TEES-development/Detectors/KerasDetectorBase.py", line 189, in classifyToXML predictions, confidences, = self.predict(labels["classification"], features["classification"], labelNames, model, numEnsemble) File "/Users/.../TEES-development/Detectors/KerasDetectorBase.py", line 908, in predict modelConfidences, , = self.predictWithModel(labels, features, labelNames, kerasModelPath) File "/Users/.../TEES-development/Detectors/KerasDetectorBase.py", line 920, in predictWithModel kerasModel = load_model(kerasModelPath) File "/Users/.../.envs/nicetwo/lib/python2.7/site-packages/keras/engine/saving.py", line 417, in load_model f = h5dict(filepath, 'r') File "/Users/.../.envs/nicetwo/lib/python2.7/site-packages/keras/utils/io_utils.py", line 197, in init 'Received: {}.'.format(type(path))) TypeError: Required Group, str or dict. Received: <type 'unicode'>.

Do you have any ideas of how I might resolve this? Many thanks!

jbjorne commented 5 years ago

Hard to tell from the error, could there be some unicode characters in the path from which you are trying to load the model? What is the "..." in the file path?

abrayne commented 5 years ago

Thank you for your help! I have found the fix and it will not be relevant to people who follow your instructions carefully. I had a more recent version of keras installed, works well with 2.0.8.