Coder Social home page Coder Social logo

Is the tdlstm built on Python2? about tdlstm HOT 4 CLOSED

bwang482 avatar bwang482 commented on September 26, 2024
Is the tdlstm built on Python2?

from tdlstm.

Comments (4)

lydemo avatar lydemo commented on September 26, 2024

And could you tell me the code is privided by the link below their paper or just be built by yourself?I tried to download their code by the link but it's unavailable now...

from tdlstm.

bwang482 avatar bwang482 commented on September 26, 2024

1), You're right, it is written in Python 2.7 as from __future__ import ....

2), This is my version of implementation and it is slightly different to Tang's version (e.g. I used relu not tanh for activation; also I didn't set the clipping threshold of softmax layer as 200 but used other techniques). His original code is written in Java I believe. There is another version: https://github.com/scaufengyang/TD-LSTM, you can check it out as well and compare performance. Hope this helps.

from tdlstm.

lydemo avatar lydemo commented on September 26, 2024

Thank you very much for sharing the link, and I wonder whether the word embedding that your code used is the pre-trained vector http://nlp.stanford.edu/data/glove.twitter.27B.zip? I use one of that, which dimensional is 100, and an error occur:
Traceback (most recent call last):
File "/Users/luoyin/Downloads/tdlstm-master/src/run.py", line 50, in
TRAIN(args, args.model)
File "/Users/luoyin/Downloads/tdlstm-master/src/optimise.py", line 181, in TRAIN
data = load_data(args, args.data, saved=args.load_data)
File "/Users/luoyin/Downloads/tdlstm-master/src/utils.py", line 15, in load_data
embedding=embedding, saved=saved, max_length=max_length)
File "../data/dataprocessor.py", line 74, in init
glove, self.glove_vec, self.glove_shape, glove_vocab = util.gensim_load_vec('../resources/wordemb/glove.twitter.27B.100d.txt')
File "../data/util.py", line 10, in gensim_load_vec
gensim_emb = gensim.models.KeyedVectors.load_word2vec_format(path, binary=False)
File "/Users/luoyin/anaconda2/lib/python2.7/site-packages/gensim/models/keyedvectors.py", line 197, in load_word2vec_format
vocab_size, vector_size = (int(x) for x in header.split()) # throws for invalid file format
File "/Users/luoyin/anaconda2/lib/python2.7/site-packages/gensim/models/keyedvectors.py", line 197, in
vocab_size, vector_size = (int(x) for x in header.split()) # throws for invalid file format
ValueError: invalid literal for int() with base 10: 'user'

from tdlstm.

bwang482 avatar bwang482 commented on September 26, 2024

Ah right, the code loads the Glove word vectors using Gensim, which means you have to add one extra line at the beginning with the number of tokens and the number of dimensions (and in this case, 1193514 100).

Check out:
https://radimrehurek.com/gensim/scripts/glove2word2vec.html

Think I will add this in the readme file, thanks for pointing out.

from tdlstm.

Related Issues (3)

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.