In [1]:
import tensorflow as tf
%matplotlib inline

In [2]:
# %load /home/guo/haplox/Github/tensorflow/tensorflow/examples/tutorials/word2vec/word2vec_basic.py
# Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

from __future__ import absolute_import
from __future__ import print_function

import tensorflow.python.platform

import collections
import math
import numpy as np
import os
import random
from six.moves import urllib
from six.moves import xrange  # pylint: disable=redefined-builtin
import tensorflow as tf
import zipfile

# Step 1: Download the data.
url = 'http://mattmahoney.net/dc/'

def maybe_download(filename, expected_bytes):
  """Download a file if not present, and make sure it's the right size."""
  if not os.path.exists(filename):
    filename, _ = urllib.request.urlretrieve(url + filename, filename)
  statinfo = os.stat(filename)
  if statinfo.st_size == expected_bytes:
    print('Found and verified', filename)
  else:
    print(statinfo.st_size)
    raise Exception(
        'Failed to verify ' + filename + '. Can you get to it with a browser?')
  return filename

filename = maybe_download('text8.zip', 31344016)


# Read the data into a string.
def read_data(filename):
  f = zipfile.ZipFile(filename)
  for name in f.namelist(): 
    return f.read(name).split() #???
  f.close()

words = read_data(filename)
print('Data size', len(words))

# Step 2: Build the dictionary and replace rare words with UNK token.
vocabulary_size = 50000

def build_dataset(words):
  count = [['UNK', -1]]
  count.extend(collections.Counter(words).most_common(vocabulary_size - 1))
  dictionary = dict()
  for word, _ in count:
    dictionary[word] = len(dictionary)
  data = list()
  unk_count = 0
  for word in words:
    if word in dictionary:
      index = dictionary[word]
    else:
      index = 0  # dictionary['UNK']
      unk_count += 1
    data.append(index)
  count[0][1] = unk_count
  reverse_dictionary = dict(zip(dictionary.values(), dictionary.keys()))
  return data, count, dictionary, reverse_dictionary

data, count, dictionary, reverse_dictionary = build_dataset(words)
del words  # Hint to reduce memory.
print('Most common words (+UNK)', count[:5])
print('Sample data', data[:10])

data_index = 0


# Step 3: Function to generate a training batch for the skip-gram model.
def generate_batch(batch_size, num_skips, skip_window):
  global data_index
  assert batch_size % num_skips == 0 #???
  assert num_skips <= 2 * skip_window
  batch = np.ndarray(shape=(batch_size), dtype=np.int32)
  labels = np.ndarray(shape=(batch_size, 1), dtype=np.int32)
  span = 2 * skip_window + 1 # [ skip_window target skip_window ]
  buffer = collections.deque(maxlen=span)
  for _ in range(span):
    buffer.append(data[data_index])
    data_index = (data_index + 1) % len(data)
  for i in range(batch_size // num_skips):
    target = skip_window  # target label at the center of the buffer
    targets_to_avoid = [ skip_window ]
    for j in range(num_skips):
      while target in targets_to_avoid:
        target = random.randint(0, span - 1)
      targets_to_avoid.append(target)
      batch[i * num_skips + j] = buffer[skip_window]
      labels[i * num_skips + j, 0] = buffer[target]
    buffer.append(data[data_index])
    data_index = (data_index + 1) % len(data)
  return batch, labels

batch, labels = generate_batch(batch_size=8, num_skips=2, skip_window=1)
for i in range(8):
  print(batch[i], '->', labels[i, 0])
  print(reverse_dictionary[batch[i]], '->', reverse_dictionary[labels[i, 0]])

# Step 4: Build and train a skip-gram model.

batch_size = 128
embedding_size = 128  # Dimension of the embedding vector.
skip_window = 1       # How many words to consider left and right.
num_skips = 2         # How many times to reuse an input to generate a label.

# We pick a random validation set to sample nearest neighbors. Here we limit the
# validation samples to the words that have a low numeric ID, which by
# construction are also the most frequent.
valid_size = 16     # Random set of words to evaluate similarity on.
valid_window = 100  # Only pick dev samples in the head of the distribution.
valid_examples = np.array(random.sample(np.arange(valid_window), valid_size))
num_sampled = 64    # Number of negative examples to sample.

graph = tf.Graph()

with graph.as_default():

  # Input data.
  train_inputs = tf.placeholder(tf.int32, shape=[batch_size]) #? shape only specified one dimension
  train_labels = tf.placeholder(tf.int32, shape=[batch_size, 1])
  valid_dataset = tf.constant(valid_examples, dtype=tf.int32)

  # Ops and variables pinned to the CPU because of missing GPU implementation
  with tf.device('/cpu:0'):
    # Look up embeddings for inputs.
    embeddings = tf.Variable(
        tf.random_uniform([vocabulary_size, embedding_size], -1.0, 1.0))
    embed = tf.nn.embedding_lookup(embeddings, train_inputs)

    # Construct the variables for the NCE loss
    nce_weights = tf.Variable(
        tf.truncated_normal([vocabulary_size, embedding_size],
                            stddev=1.0 / math.sqrt(embedding_size)))
    nce_biases = tf.Variable(tf.zeros([vocabulary_size]))

  # Compute the average NCE loss for the batch.
  # tf.nce_loss automatically draws a new sample of the negative labels each
  # time we evaluate the loss.
  loss = tf.reduce_mean(
      tf.nn.nce_loss(nce_weights, nce_biases, embed, train_labels,
                     num_sampled, vocabulary_size))

  # Construct the SGD optimizer using a learning rate of 1.0.
  optimizer = tf.train.GradientDescentOptimizer(1.0).minimize(loss)

  # Compute the cosine similarity between minibatch examples and all embeddings.
  norm = tf.sqrt(tf.reduce_sum(tf.square(embeddings), 1, keep_dims=True))
  normalized_embeddings = embeddings / norm
  valid_embeddings = tf.nn.embedding_lookup(
      normalized_embeddings, valid_dataset)
  similarity = tf.matmul(
      valid_embeddings, normalized_embeddings, transpose_b=True)

# Step 5: Begin training.
num_steps = 100001

with tf.Session(graph=graph) as session:
  # We must initialize all variables before we use them.
  tf.initialize_all_variables().run()
  print("Initialized")

  average_loss = 0
  for step in xrange(num_steps):
    batch_inputs, batch_labels = generate_batch(
        batch_size, num_skips, skip_window)
    feed_dict = {train_inputs : batch_inputs, train_labels : batch_labels}

    # We perform one update step by evaluating the optimizer op (including it
    # in the list of returned values for session.run()
    _, loss_val = session.run([optimizer, loss], feed_dict=feed_dict)
    average_loss += loss_val

    if step % 2000 == 0:
      if step > 0:
        average_loss /= 2000
      # The average loss is an estimate of the loss over the last 2000 batches.
      print("Average loss at step ", step, ": ", average_loss)
      average_loss = 0

    # Note that this is expensive (~20% slowdown if computed every 500 steps)
    if step % 10000 == 0:
      sim = similarity.eval()
      for i in xrange(valid_size):
        valid_word = reverse_dictionary[valid_examples[i]]
        top_k = 8 # number of nearest neighbors
        nearest = (-sim[i, :]).argsort()[1:top_k+1]
        log_str = "Nearest to %s:" % valid_word
        for k in xrange(top_k):
          close_word = reverse_dictionary[nearest[k]]
          log_str = "%s %s," % (log_str, close_word)
        print(log_str)
  final_embeddings = normalized_embeddings.eval()

# Step 6: Visualize the embeddings.

def plot_with_labels(low_dim_embs, labels, filename='tsne.png'):
  assert low_dim_embs.shape[0] >= len(labels), "More labels than embeddings"
  plt.figure(figsize=(18, 18))  #in inches
  for i, label in enumerate(labels):
    x, y = low_dim_embs[i,:]
    plt.scatter(x, y)
    plt.annotate(label,
                 xy=(x, y),
                 xytext=(5, 2),
                 textcoords='offset points',
                 ha='right',
                 va='bottom')

  plt.savefig(filename)

try:
  from sklearn.manifold import TSNE
  import matplotlib.pyplot as plt

  tsne = TSNE(perplexity=30, n_components=2, init='pca', n_iter=5000)
  plot_only = 500
  low_dim_embs = tsne.fit_transform(final_embeddings[:plot_only,:])
  labels = [reverse_dictionary[i] for i in xrange(plot_only)]
  plot_with_labels(low_dim_embs, labels)

except ImportError:
  print("Please install sklearn and matplotlib to visualize embeddings.")


Found and verified text8.zip
Data size 17005207
Most common words (+UNK) [['UNK', 418391], ('the', 1061396), ('of', 593677), ('and', 416629), ('one', 411764)]
Sample data [5239, 3084, 12, 6, 195, 2, 3137, 46, 59, 156]
3084 -> 5239
originated -> anarchism
3084 -> 12
originated -> as
12 -> 3084
as -> originated
12 -> 6
as -> a
6 -> 12
a -> as
6 -> 195
a -> term
195 -> 6
term -> a
195 -> 2
term -> of
Initialized
Average loss at step  0 :  280.859313965
Nearest to on: considering, aman, harmonization, irrelevent, subcommittee, limericks, dreamworks, charybdis,
Nearest to called: tile, physiologic, spear, sacd, bump, dien, complicated, icaza,
Nearest to his: talks, spawned, cartoonish, goldie, thursday, ashland, pizzicato, orleans,
Nearest to used: porphyry, manure, doctrine, lloyd, fula, chase, paces, bowling,
Nearest to when: parasite, inspectors, serious, diaspora, keats, temps, unlike, npc,
Nearest to years: gallia, hurry, canonic, hydrazine, operationally, jonathon, conflicts, beat,
Nearest to UNK: aa, installs, steps, confessor, manchester, banished, shoeless, faction,
Nearest to had: amateur, lacaille, grimaldi, carelessness, founds, robot, firebird, eerdmans,
Nearest to will: scheduler, inhibition, surgery, iris, physiocrats, affording, thru, courtroom,
Nearest to this: confidentiality, aramaeans, session, proportionally, eras, ossetia, enumerated, lendl,
Nearest to all: equilateral, folds, piece, unimpressed, wrap, gazetteer, ona, bahraini,
Nearest to use: kaplan, phrygia, palme, preconditions, yockey, strut, estimate, filipinos,
Nearest to into: revitalize, nichiren, dos, adele, landlocked, minamoto, khyber, stenosis,
Nearest to also: suppress, grabs, earhart, prom, tectonic, rise, gonzaga, traceable,
Nearest to world: winding, mandragora, eng, cesare, schaff, imports, rhyolite, lillard,
Nearest to american: clashes, sancho, ovarian, wives, renouncing, mel, referees, subsidiaries,
Average loss at step  2000 :  114.08512473
Average loss at step  4000 :  52.4788641708
Average loss at step  6000 :  33.2105162389
Average loss at step  8000 :  23.4818150024
Average loss at step  10000 :  18.1345670934
Nearest to on: in, aberdeen, from, tango, considering, contributions, of, austin,
Nearest to called: turned, again, vs, messagepad, problem, victoriae, spear, cc,
Nearest to his: the, orleans, khwarizmi, centered, spawned, reginae, austin, doyle,
Nearest to used: mathbf, chase, doctrine, analogue, anarchism, egg, phi, omnibus,
Nearest to when: serious, unlike, tango, throughout, parasite, diaspora, adventurer, legislation,
Nearest to years: five, victoriae, conflicts, reginae, predominantly, subfamily, sentence, summer,
Nearest to UNK: and, victoriae, agave, cl, phi, austin, the, one,
Nearest to had: and, szasz, amateur, letter, dagny, was, succeeds, place,
Nearest to will: surgery, f, southeast, lens, founder, abugida, argentine, colloquial,
Nearest to this: the, a, assert, which, guilty, each, victoriae, eras,
Nearest to all: gang, completed, produced, victoriae, reginae, piece, involving, vs,
Nearest to use: estimate, kaplan, victoriae, gland, thought, idea, ada, sagan,
Nearest to into: launched, of, dos, landlocked, in, magic, telephones, reginae,
Nearest to also: phi, rise, two, it, tectonic, vs, var, reginae,
Nearest to world: lift, vs, imports, reginae, fins, eighteen, occupy, visited,
Nearest to american: clashes, and, um, in, renouncing, perception, marston, hurt,
Average loss at step  12000 :  13.959017045
Average loss at step  14000 :  11.8729876691
Average loss at step  16000 :  9.88722752297
Average loss at step  18000 :  8.69488968277
Average loss at step  20000 :  7.78882094681
Nearest to on: in, from, and, for, at, tango, agouti, gap,
Nearest to called: tile, dasyprocta, again, messagepad, turned, problem, comic, spear,
Nearest to his: the, their, dasyprocta, a, stadia, many, agouti, s,
Nearest to used: dasyprocta, agouti, galaxy, chase, analogue, mathbf, circ, dominant,
Nearest to when: was, serious, tango, throughout, adventurer, and, in, inspectors,
Nearest to years: five, circ, predominantly, victoriae, summer, conflicts, reginae, subfamily,
Nearest to UNK: dasyprocta, agouti, victoriae, agave, badges, isu, phi, imran,
Nearest to had: was, is, also, and, imran, szasz, have, has,
Nearest to will: courtroom, abugida, surgery, implemented, would, imran, southeast, inherent,
Nearest to this: the, which, a, it, he, agouti, each, albuquerque,
Nearest to all: dasyprocta, completed, these, agouti, gang, involving, theta, portraits,
Nearest to use: estimate, kaplan, baptists, idea, haer, dasyprocta, meat, burgundy,
Nearest to into: in, of, actaeon, is, dasyprocta, at, six, gnaeus,
Nearest to also: it, which, not, phi, dasyprocta, had, that, he,
Nearest to world: lift, vs, eighteen, visited, fins, occupy, acacia, ordained,
Nearest to american: and, sancho, clashes, um, victoriae, in, hazmi, reginae,
Average loss at step  22000 :  7.28776461339
Average loss at step  24000 :  6.95240174794
Average loss at step  26000 :  6.73862758803
Average loss at step  28000 :  6.18576519275
Average loss at step  30000 :  6.14067970061
Nearest to on: in, from, at, and, for, by, agouti, during,
Nearest to called: dasyprocta, tile, toile, again, mutagenic, comic, messagepad, UNK,
Nearest to his: their, the, s, its, her, stadia, a, any,
Nearest to used: dasyprocta, agouti, galaxy, akita, known, analogue, lloyd, tunings,
Nearest to when: was, four, aegeus, if, in, and, seven, is,
Nearest to years: five, circ, predominantly, gallia, four, summer, six, performance,
Nearest to UNK: dasyprocta, victoriae, agouti, akita, badges, bos, cl, phi,
Nearest to had: was, have, has, is, also, szasz, imran, were,
Nearest to will: would, to, tunings, abugida, inherent, aosta, implemented, courtroom,
Nearest to this: which, the, it, a, agouti, each, dasyprocta, that,
Nearest to all: these, dasyprocta, completed, tunings, agouti, gang, portraits, bolt,
Nearest to use: estimate, kaplan, preconditions, baptists, burgundy, idea, yankees, haer,
Nearest to into: in, at, on, actaeon, dasyprocta, for, three, of,
Nearest to also: which, it, not, phi, dasyprocta, that, had, vs,
Nearest to world: lift, visited, occupy, eighteen, vs, fins, anarchists, akita,
Nearest to american: clashes, and, sancho, abet, english, one, um, victoriae,
Average loss at step  32000 :  5.84486813402
Average loss at step  34000 :  5.84629894781
Average loss at step  36000 :  5.66225241768
Average loss at step  38000 :  5.23412906814
Average loss at step  40000 :  5.44353548157
Nearest to on: in, from, at, agouti, dasyprocta, for, during, tango,
Nearest to called: UNK, dasyprocta, and, tile, toile, wider, mutagenic, comic,
Nearest to his: their, the, its, her, s, stadia, any, heaters,
Nearest to used: agouti, dasyprocta, akita, known, galaxy, analogue, tunings, victoriae,
Nearest to when: if, was, in, throughout, inspectors, is, albury, six,
Nearest to years: circ, four, five, six, predominantly, gallia, canonic, summer,
Nearest to UNK: dasyprocta, victoriae, agouti, akita, agave, abet, albury, badges,
Nearest to had: was, has, have, were, is, also, szasz, imran,
Nearest to will: would, to, can, inherent, should, tunings, abugida, implemented,
Nearest to this: which, the, it, that, a, some, each, agouti,
Nearest to all: these, adamantium, dasyprocta, tunings, some, piezoelectric, completed, many,
Nearest to use: estimate, kaplan, preconditions, burgundy, idea, yankees, baptists, dasyprocta,
Nearest to into: in, on, with, theatrical, at, from, for, by,
Nearest to also: which, it, not, that, phi, dasyprocta, had, preservation,
Nearest to world: occupy, lift, advisor, chest, visited, eighteen, fins, vs,
Nearest to american: clashes, sancho, abet, UNK, english, british, and, victoriae,
Average loss at step  42000 :  5.32581162739
Average loss at step  44000 :  5.32657103992
Average loss at step  46000 :  5.26155053818
Average loss at step  48000 :  5.04004849792
Average loss at step  50000 :  5.15292198551
Nearest to on: in, from, at, agouti, through, for, dasyprocta, tango,
Nearest to called: UNK, dasyprocta, and, tile, mutagenic, comic, wider, explains,
Nearest to his: their, its, the, her, s, stadia, any, abakan,
Nearest to used: agouti, known, dasyprocta, akita, analogue, galaxy, bowling, victoriae,
Nearest to when: if, seven, six, four, is, throughout, but, as,
Nearest to years: canonic, four, circ, months, gallia, summer, five, predominantly,
Nearest to UNK: dasyprocta, victoriae, agouti, thibetanus, akita, agave, albury, cl,
Nearest to had: has, was, have, were, is, imran, gundam, also,
Nearest to will: would, can, to, could, should, may, tunings, might,
Nearest to this: which, the, it, thibetanus, agouti, that, a, dasyprocta,
Nearest to all: these, adamantium, dasyprocta, tunings, some, many, bolt, agouti,
Nearest to use: estimate, kaplan, burgundy, idea, preconditions, yankees, dasyprocta, baptists,
Nearest to into: thibetanus, from, theatrical, with, in, on, at, dasyprocta,
Nearest to also: which, not, it, phi, had, dasyprocta, often, preservation,
Nearest to world: occupy, lift, advisor, chest, fins, eighteen, alliance, wave,
Nearest to american: clashes, sancho, and, english, british, abet, french, victoriae,
Average loss at step  52000 :  5.18222336411
Average loss at step  54000 :  5.09144893062
Average loss at step  56000 :  5.06417336178
Average loss at step  58000 :  5.12343637347
Average loss at step  60000 :  4.95176270407
Nearest to on: in, tamarin, at, microcebus, through, from, upon, agouti,
Nearest to called: dasyprocta, and, tile, comic, wider, toile, explains, mutagenic,
Nearest to his: their, its, her, the, s, cebus, stadia, microcebus,
Nearest to used: known, agouti, dasyprocta, galaxy, bowling, akita, analogue, victoriae,
Nearest to when: if, as, throughout, but, where, was, in, at,
Nearest to years: four, canonic, circ, months, six, summer, five, predominantly,
Nearest to UNK: tamarin, dasyprocta, agouti, cebus, akita, callithrix, victoriae, agave,
Nearest to had: has, have, was, were, lemmy, imran, is, gundam,
Nearest to will: would, can, could, should, may, to, might, tunings,
Nearest to this: which, it, the, that, michelob, cebus, agouti, thibetanus,
Nearest to all: these, adamantium, some, microcebus, dasyprocta, tunings, callithrix, many,
Nearest to use: estimate, kaplan, preconditions, callithrix, burgundy, idea, yankees, ssbn,
Nearest to into: from, theatrical, on, thibetanus, under, in, with, through,
Nearest to also: which, not, it, often, callithrix, now, that, dasyprocta,
Nearest to world: occupy, lift, alliance, chest, advisor, retrieve, eighteen, recorder,
Nearest to american: clashes, british, sancho, french, english, abet, and, victoriae,
Average loss at step  62000 :  4.79516645539
Average loss at step  64000 :  4.80171104741
Average loss at step  66000 :  4.96777187645
Average loss at step  68000 :  4.90626119196
Average loss at step  70000 :  4.77082284975
Nearest to on: in, through, tamarin, upon, from, at, microcebus, agouti,
Nearest to called: dasyprocta, UNK, and, comic, tile, wider, explains, ssbn,
Nearest to his: their, its, her, the, cebus, s, microcebus, stadia,
Nearest to used: known, agouti, dasyprocta, analogue, akita, callithrix, victoriae, canaris,
Nearest to when: if, but, where, as, was, while, before, throughout,
Nearest to years: months, four, canonic, circ, six, five, summer, eight,
Nearest to UNK: dasyprocta, tamarin, thaler, agouti, victoriae, callithrix, microcebus, akita,
Nearest to had: has, have, was, were, is, imran, lemmy, workshop,
Nearest to will: would, can, could, may, should, might, to, must,
Nearest to this: which, it, the, that, michelob, cebus, agouti, thibetanus,
Nearest to all: these, adamantium, some, ischemia, many, microcebus, tunings, dasyprocta,
Nearest to use: estimate, kaplan, preconditions, callithrix, idea, burgundy, ssbn, yankees,
Nearest to into: from, theatrical, in, through, thibetanus, on, under, hurrian,
Nearest to also: which, upanija, often, now, not, it, usually, still,
Nearest to world: occupy, lift, chest, alliance, advisor, tamarin, eighteen, retrieve,
Nearest to american: british, clashes, french, english, sancho, abet, victoriae, pulau,
Average loss at step  72000 :  4.80183202767
Average loss at step  74000 :  4.76393924847
Average loss at step  76000 :  4.86331249595
Average loss at step  78000 :  4.80988439047
Average loss at step  80000 :  4.81393554378
Nearest to on: in, through, from, at, upon, tamarin, microcebus, for,
Nearest to called: dasyprocta, and, explains, callisto, tile, ssbn, agouti, mutagenic,
Nearest to his: their, her, its, the, cebus, s, microcebus, stadia,
Nearest to used: known, agouti, analogue, dasyprocta, bowling, identified, akita, callithrix,
Nearest to when: if, where, before, while, but, thibetanus, dasyprocta, as,
Nearest to years: months, four, canonic, circ, days, five, eight, summer,
Nearest to UNK: thaler, dasyprocta, tamarin, callithrix, victoriae, cebus, akita, agouti,
Nearest to had: has, have, was, were, lemmy, imran, miyazaki, gundam,
Nearest to will: would, can, could, may, should, might, must, to,
Nearest to this: which, it, the, michelob, cebus, that, one, agouti,
Nearest to all: these, adamantium, some, many, microcebus, tunings, ischemia, callithrix,
Nearest to use: estimate, kaplan, preconditions, idea, burgundy, callithrix, wct, iit,
Nearest to into: from, through, theatrical, thibetanus, under, on, vec, with,
Nearest to also: which, upanija, often, now, it, still, not, usually,
Nearest to world: lift, occupy, chest, advisor, alliance, un, retrieve, athlon,
Nearest to american: british, french, clashes, english, sancho, abet, irish, reginae,
Average loss at step  82000 :  4.79473013091
Average loss at step  84000 :  4.78352263594
Average loss at step  86000 :  4.73409775889
Average loss at step  88000 :  4.69508362794
Average loss at step  90000 :  4.77335617042
Nearest to on: in, tamarin, upon, through, at, from, microcebus, agouti,
Nearest to called: dasyprocta, and, UNK, agouti, explains, tile, garc, ssbn,
Nearest to his: their, her, its, the, s, cebus, microcebus, stadia,
Nearest to used: known, agouti, analogue, seen, dasyprocta, akita, victoriae, identified,
Nearest to when: if, while, where, before, six, but, thibetanus, as,
Nearest to years: months, days, canonic, circ, five, summer, times, degrees,
Nearest to UNK: thaler, tamarin, dasyprocta, callithrix, agouti, victoriae, cebus, thibetanus,
Nearest to had: has, have, was, were, miyazaki, workshop, imran, lemmy,
Nearest to will: would, can, may, could, should, might, must, to,
Nearest to this: it, which, the, cebus, michelob, that, agouti, some,
Nearest to all: these, adamantium, some, many, microcebus, tunings, ischemia, callithrix,
Nearest to use: estimate, callithrix, preconditions, idea, wct, burgundy, iit, kaplan,
Nearest to into: from, through, theatrical, thibetanus, under, with, vec, koi,
Nearest to also: which, often, upanija, now, not, usually, still, sympathized,
Nearest to world: lift, chest, occupy, alliance, tamarin, retrieve, advisor, athlon,
Nearest to american: british, french, english, clashes, sancho, abet, pulau, reginae,
Average loss at step  92000 :  4.70673664463
Average loss at step  94000 :  4.62530295384
Average loss at step  96000 :  4.73409918094
Average loss at step  98000 :  4.61511537534
Average loss at step  100000 :  4.67487913489
Nearest to on: in, upon, through, tamarin, at, during, around, agouti,
Nearest to called: and, dasyprocta, UNK, garc, considered, explains, callisto, wider,
Nearest to his: their, her, its, the, s, cebus, stadia, microcebus,
Nearest to used: known, agouti, seen, analogue, dasyprocta, victoriae, found, callithrix,
Nearest to when: if, while, before, where, but, though, as, thibetanus,
Nearest to years: months, days, canonic, four, six, circ, degrees, times,
Nearest to UNK: thaler, tamarin, dasyprocta, agouti, victoriae, callithrix, microcebus, thibetanus,
Nearest to had: has, have, was, were, miyazaki, imran, lemmy, is,
Nearest to will: would, can, may, could, should, might, must, to,
Nearest to this: which, it, the, that, michelob, cebus, gaku, one,
Nearest to all: these, some, adamantium, many, microcebus, various, tunings, both,
Nearest to use: estimate, burgundy, wct, callithrix, preconditions, idea, iit, kaplan,
Nearest to into: through, from, theatrical, thibetanus, under, in, on, with,
Nearest to also: which, often, upanija, now, usually, never, still, not,
Nearest to world: chest, occupy, lift, alliance, athlon, retrieve, advisor, un,
Nearest to american: british, french, english, clashes, irish, reginae, pulau, thibetanus,
/usr/lib/pymodules/python2.7/matplotlib/collections.py:548: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._edgecolors == 'face':

In [ ]: