Comments (3)
It happens when it processes the line which contains "...", you can simply add the conditional statement if len(content) != 301: continue
or try modifying word2vec[word2id[content[0]]] = np.array(list(map(float, content[1:])))
to word2vec[word2id[content[:-300]]] = np.array(list(map(float, content[-300:])))
from ram.
Woww. Thanks a lot for your respond. I fixed it and it runs.
I think it is necessary to mention some other points in this project which may help other in future:
first of all, I replaced word2vec[word2id[content[0]]] = np.array(list(map(float, content[1:])))
with word2vec[word2id[content[:-300]]] = np.array(list(map(float, content[-300:])))
, but another error appeared, it was about hashing error:
Loading pre-trained word vectors ...
Traceback (most recent call last):
File "main.py", line 47, in
tf.app.run()
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "main.py", line 38, in main
FLAGS.word2vec = load_word_embeddings(FLAGS.embedding_fname, FLAGS.embedding_dim, FLAGS.word2id)
File "/content/RAM/utils.py", line 160, in load_word_embeddings
word2vec[word2id[content[:-300]]] = np.array(list(map(float, content[-300:])))
TypeError: unhashable type: 'list'
then I use the other solution that you said. I mean using if len(content) != 301: continue
in load word embeddings function in utils.py . finally it works but it pointed to another issue. the error was this:
Traceback (most recent call last):
File "main.py", line 47, in
tf.app.run()
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "main.py", line 38, in main
FLAGS.word2vec = load_word_embeddings(FLAGS.embedding_fname, FLAGS.embedding_dim, FLAGS.word2id)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/platform/flags.py", line 88, in setattr
return self.dict['__wrapped'].setattr(name, value)
File "/usr/local/lib/python3.6/dist-packages/absl/flags/_flagvalues.py", line 499, in setattr
return self._set_unknown_flag(name, value)
File "/usr/local/lib/python3.6/dist-packages/absl/flags/_flagvalues.py", line 375, in _set_unknown_flag
raise _exceptions.UnrecognizedFlagError(name, value)
absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'word2vec'
but with your previous tip I fixed it by defining word2vec before main in main.py
tf.app.flags.DEFINE_string('word2vec', '', 'word to vec')
So i appreciate the time that you gave me and helped me in this. the paper and its performance is great. I want to delve deeper in this and find out is it possible to improve it or not?! if I get good result certainly i share it with you here. Again, Thanks a lot
from ram.
I'm sorry that I haven't verified my modification. And I find the best way to correct the problem: just modify content = line.strip().split()
to content = line.strip().split(' ')
from ram.
Related Issues (12)
- 关于准确率的问题 HOT 1
- 运行代码中遇到了错误,想请教一下。 HOT 1
- How to make confusion matrix on this model ?
- Glove Embedding HOT 1
- 关于变长序列的取平均操作 HOT 2
- 我直接跑出来的结果无法达到reported的性能,而且差很多 HOT 3
- Help HOT 1
- Help HOT 1
- Question HOT 2
- Using CNN with Bi-LSTM HOT 3
- Visualize the attention HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ram.