Comments (8)
Looks okay. embedding_weights must be a list of len=1 of ndarray with shape=(len(vocabulary_inv), num_features). It was made a list for compatibility with keras layer.set_weights()
from cnn-for-sentence-classification-in-keras.
Hi,
for w in vocabulary_inv
is list of words, not indexes.
from cnn-for-sentence-classification-in-keras.
Hi,
I appreciate for your instant reply.
In here, you mentioned that it is dict {int:str}.
In for w in vocabulary_inv , is w a list of words?
from cnn-for-sentence-classification-in-keras.
Sorry, vocabulary_inv is list of strings, not dict. And w is string (i.e. word)
from cnn-for-sentence-classification-in-keras.
Sorry to disturb you again. I still feel it is strange...
In sentiment_cnn.py, vocabulary_inv is a dictionary object {int:str}. The vocabulary_inv is inputted to train_word2vec as a part of parameters then.
vocabulary = imdb.get_word_index()
vocabulary_inv = dict((v, k) for k, v in vocabulary.items())
vocabulary_inv[0] = "<PAD/>"
In w2v.py, I don't see where vocabulary_inv is converted to a list type object.
And I added print(type(vocabulary_inv )) in w2v.py. The program printed <class 'dict'> out.
from cnn-for-sentence-classification-in-keras.
This discrepancy arose after I switched to new [keras] data source. In previous major version data source was data_helpers.load_data() and it returns vocabulary_inv as list. I will fix it when I have more time. Should be dict everywhere
from cnn-for-sentence-classification-in-keras.
Thank you very much!!!
I wrote the following code. I know that is a little waste of memory...
For the purpose of solving problem , is the code right?
vocabulary_inv_list = [vocabulary_inv[i] for i in range(0, len(vocabulary_inv))]
embedding_weights = [np.array([embedding_model[w] if w in embedding_model
else np.random.uniform(-0.25, 0.25, embedding_model.vector_size)
for w in vocabulary_inv_list])]
from cnn-for-sentence-classification-in-keras.
Please see updated version
from cnn-for-sentence-classification-in-keras.
Related Issues (20)
- error when retraining word vector HOT 3
- Error in w2v.py line 52 HOT 4
- TypeError: __init__() takes at least 3 arguments (2 given) HOT 1
- Running instructions HOT 1
- expected input_4 to have shape (None, 185) but got array with shape (1665, 35) HOT 1
- how to run trained model on sample sentence HOT 1
- Trying to replicate the results obtained with denny brtiz's code HOT 8
- Using local directory dataset does not yield the marked results HOT 1
- Using Glove or GoogleNews? HOT 1
- Wrong model for Y.Kim's TextCNN HOT 1
- Using pre-trained google word embeddings HOT 3
- Negative dimension size caused by subtracting 3 from 1
- Only words, no sentences HOT 1
- 问题咨询 HOT 8
- How to train the model with multi-class dataset HOT 2
- accuracy HOT 3
- The model always predicts the same label HOT 1
- Two fully-connected layers after convolutions HOT 1
- as for the CNN-non-static model initialization issue
- Multiple Dropouts different from Original Paper and Denny Britz
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 cnn-for-sentence-classification-in-keras.