courses/machine_learning/deepdive/09_sequence/word2vec/word2vec.py
def save_vocab(self):
    """Save the vocabulary to a file so the model can be reloaded."""
    opts = self._options
    with open(os.path.join(opts.save_path, "vocab.txt"), "w") as f:
      for i in xrange(opts.vocab_size):
        vocab_word = tf.compat.as_text(opts.vocab_words[i]).encode("utf-8")
        f.write("%s %d\n" % (vocab_word,
                             opts.vocab_counts[i]))
    np.savetxt(os.path.join(opts.save_path, "vectors.txt"), self._nemb.eval())
Save the vocabulary to a file so the model can be reloaded.
Save the vocabulary to a file so the model can be reloaded.
Save the vocabulary to a file so the model can be reloaded .
def save_vocab(self):
    opts = self._options
    with open(os.path.join(opts.save_path, "vocab.txt"), "w") as f:
      for i in xrange(opts.vocab_size):
        vocab_word = tf.compat.as_text(opts.vocab_words[i]).encode("utf-8")
        f.write("%s %d\n" % (vocab_word,
                             opts.vocab_counts[i]))
    np.savetxt(os.path.join(opts.save_path, "vectors.txt"), self._nemb.eval())
def save_vocab ( self ) : opts = self . _options with open ( os . path . join ( opts . save_path , "vocab.txt" ) , "w" ) as f : for i in xrange ( opts . vocab_size ) : vocab_word = tf . compat . as_text ( opts . vocab_words [ i ] ) . encode ( "utf-8" ) f . write ( "%s %d\n" % ( vocab_word , opts . vocab_counts [ i ] ) ) np . savetxt ( os . path . join ( opts . save_path , "vectors.txt" ) , self . _nemb . eval ( ) )
Save the vocabulary to a file so the model can be reloaded.
Save the vocabulary to a file so the model can be reloaded .
"""Save the vocabulary to a file so the model can be reloaded."""
self