inspirehep / magpie

Deep neural network framework for multi-label text classification
MIT License
683 stars 192 forks source link

Getting TypeError: 'NoneType' object is not callable in Ubuntu 16.04 54 bit version Python 3 with virtual environment #132

Open rajeshkumargp opened 6 years ago

rajeshkumargp commented 6 years ago

magpie team, I have tried to execute the below code in Ubuntu 16.04 64 bit version with Python 3 in virtual environment.I am getting TypeError: 'NoneType' object is not callable.

Code:

from magpie import Magpie
magpie = Magpie()
magpie.train_word2vec('magpie/data/hep-categories', vec_dim=100)
magpie.fit_scaler('magpie/data/hep-categories')
magpie.init_word_vectors('magpie/data/hep-categories', vec_dim=100)
labels = ['Gravitation and Cosmology', 'Experiment-HEP', 'Theory-HEP']
magpie.train('magpie/data/hep-categories', labels, test_ratio=0.2, epochs=30)
print("Hello PREDICTED OUTPUT will be printed After now  ")
print("********************")
print(magpie.predict_from_text('Stephen Hawking studies black holes'))
#magpie.predict_from_file('data/hep-categories/1002413.txt')

and I am getting the below error:

Hello PREDICTED OUTPUT will be printed After now  
********************
[('Gravitation and Cosmology', 0.9992586), ('Theory-HEP', 0.88344705), ('Experiment-HEP', 0.000537122)]
Exception ignored in: <bound method BaseSession.__del__ of <tensorflow.python.client.session.Session object at 0x7f88d6426ef0>>
Traceback (most recent call last):
  File "/home/user/magpie_git/magpie_py3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 712, in __del__
TypeError: 'NoneType' object is not callable

My virtual environment names is 'magpie_py3' Can you please resolve it .

jstypka commented 6 years ago

Your model seems to be trained correctly and delivers predictions as you can see. The error occurs with closing the session and doesn't seem to me like it's connected to Magpie.

rajeshkumargp commented 6 years ago

Yes, That is the issue .
If I execute the same code with Python 2, Its is working fine. I am not getting any error like as above.

Please suggest me how to rectify the above issue in Python 3.