Coder Social home page Coder Social logo

about the code about ram HOT 3 CLOSED

lpq29743 avatar lpq29743 commented on July 23, 2024
about the code

from ram.

Comments (3)

lpq29743 avatar lpq29743 commented on July 23, 2024 2

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.

Mahdilb avatar Mahdilb commented on July 23, 2024 1

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.

lpq29743 avatar lpq29743 commented on July 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.