Keras implementation of Doc2Vec
Project description
Keras2Vec
A Keras implementation, with gpu support, of the Doc2Vec network
Installation
This package can be installed using pip: pip install keras2vec
Example Usage
from keras2vec.keras2vec import Keras2Vec
from keras2vec.document import Document
from sklearn.metrics.pairwise import cosine_similarity
docs = [Document(1, [], "Test Document 01"),
Document(1, [], "Test Document 02"),
Document(1, [], "Test Document 03"),
Document(1, [], "Test Document 04"),
Document(2, [], "Random words to experiment"),
Document(2, [], "Random words to experiment"),
Document(2, [], "Random words to experiment"),
Document(2, [], "Random words to experiment"),
]
doc2vec = Keras2Vec(docs)
doc2vec.build_model()
doc2vec.fit(5)
embeddings = doc2vec.train_model.get_layer('doc_embedding').get_weights()[0]
doc1 = embeddings[0].reshape(1, -1)
doc2 = embeddings[0].reshape(1, -1)
cosine_similarity(doc1, doc2)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Keras2Vec-0.0.1.tar.gz
(5.0 kB
view hashes)
Built Distribution
Close
Hashes for Keras2Vec-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f0c9435256c522f1a658a2f4a8d20aef333d9f5d1dd1b58a766841df08711c7 |
|
MD5 | e3f58183aa8d9ea0e9b53fe71bb07c4f |
|
BLAKE2b-256 | bcc8a7c048ea4e58f87d737727307337ca6ea582110384fb300e458f7456a31b |