Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Jorigorn opened this issue Aug 31, 2018 · 1 comment
Open

Comments

@Jorigorn
Copy link

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

@clairett
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants