Skip to content

Commit

Permalink
Update homepage (dmlc#75)
Browse files Browse the repository at this point in the history
* Update homepage

* cos sim
  • Loading branch information
astonzhang authored and szha committed Apr 23, 2018
1 parent 0b1c8ea commit e2e00b2
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ models. This toolkit offers four main features:
4. Community supports


This toolkit assume users has basic knowledges about deep learning and
NLP. Otherwise, please refer to introduction course such as `Stanford
CS224n <http://web.stanford.edu/class/cs224n/>`_.
This toolkit assumes that users have basic knowledge about deep learning and
NLP. Otherwise, please refer to an introduction course such as
`Deep Learning---The Straight Dope <http://gluon.mxnet.io/>`_ or
`Stanford CS224n <http://web.stanford.edu/class/cs224n/>`_.

.. note::

Expand All @@ -26,19 +27,19 @@ Installation

GluonNLP relies on the recent version of MXNet. The easiest way to install MXNet
is through `pip <https://pip.pypa.io/en/stable/installing/>`_. The following
command installs a nightly build CPU version of MXNet.
command installs a nightly built CPU version of MXNet.

.. code-block:: bash
pip install --pre mxnet
.. note::

There are other pre-build MXNet packages that enables GPU supports and
There are other pre-build MXNet packages that enable GPU supports and
accelerate CPU performance, please refer to `this tutorial
<http://gluon-crash-course.mxnet.io/mxnet_packages.html>`_ for details. Some
training scripts are recommended to run on GPUs, if you don't have a GPU
machine at hands, you may consider to `run on AWS
machine at hands, you may consider `running on AWS
<http://gluon-crash-course.mxnet.io/use_aws.html>`_.


Expand All @@ -52,8 +53,8 @@ Then install the GluonNLP toolkit by
A Quick Example
----------------

Here is a quick example that download and create a word embedding model and then
compare the similarity between two words.
Here is a quick example that downloads and creates a word embedding model and then
computes the cosine similarity between two words.

..
(You can click the go button on the
Expand All @@ -76,10 +77,13 @@ compare the similarity between two words.
import mxnet as mx
import gluonnlp as nlp
glove = nlp.embedding.create('glove', source='glove.6B.50d.txt')
# Create a GloVe word embedding.
glove = nlp.embedding.create('glove', source='glove.6B.50d')
# Obtain vectors for 'baby' and 'infant' in the GloVe word embedding.
baby, infant = glove['baby'], glove['infant']
def cos_similarity(vec1, vec2):
# Normalize the dot product of two vectors with the L2-norm product.
return mx.nd.dot(vec1, vec2) / (vec1.norm() * vec2.norm())
print(cos_similarity(baby, infant))
Expand Down

0 comments on commit e2e00b2

Please sign in to comment.