Skip to main content

Keras implementation of Doc2Vec

Project description


A Keras implementation, with gpu support, of the Doc2Vec network


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)

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.

Files for Keras2Vec, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size Keras2Vec-0.0.1-py3-none-any.whl (7.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size Keras2Vec-0.0.1.tar.gz (5.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page