Deep-Memory-Network icon indicating copy to clipboard operation
Deep-Memory-Network copied to clipboard

AttributeError: 'array.array' object has no attribute 'tobytes'

Open Jorigorn opened this issue 6 years ago • 1 comments

Thanks for sharing the code, I am using python 2, got this error: using coding utf-8, otherwise will got another coding error.

import sys

reload(sys) sys.setdefaultencoding('utf8')

(deepMemNet) zchen@hdp-node11:~/Deep-Memory-Network$ python main.py --show True /home/zchen/anaconda2/lib/python2.7/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters 0%| | 778/2195895 [00:00<09:25, 3885.03it/s]Traceback (most recent call last): File "main.py", line 73, in tf.app.run()
File "/home/zchen/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 124, in run _sys.exit(main(argv)) File "main.py", line 46, in main embeddings = init_word_embeddings(FLAGS.pretrain_embeddings, word_set, FLAGS.edim) File "/home/zchen/Deep-Memory-Network/data.py", line 16, in init_word_embeddings embedding = GloveEmbedding(tokens[1], d_emb=edim, show_progress=True) File "/home/zchen/anaconda2/lib/python2.7/site-packages/embeddings/glove.py", line 48, in init self.load_word2emb(show_progress=show_progress) File "/home/zchen/anaconda2/lib/python2.7/site-packages/embeddings/glove.py", line 81, in load_word2emb self.insert_batch(batch) File "/home/zchen/anaconda2/lib/python2.7/site-packages/embeddings/embedding.py", line 139, in insert_batch binarized = [(word, array('f', emb).tobytes()) for word, emb in batch] AttributeError: 'array.array' object has no attribute 'tobytes' Exception KeyError: KeyError(<weakref at 0x7f70f9d98b50; to 'tqdm' at 0x7f70f9cc1c10>,) in <bound method tqdm.del of 0%| | 778/2195895 [00:00<24:56, 1467.16it/s]> ignored

Jorigorn avatar Aug 31 '18 15:08 Jorigorn

Hi, I just add requirements.txt with dependencies required. I'm sorry I cannot replicate your error. BTW, the codes should work on Python 3

clairett avatar Aug 31 '18 18:08 clairett