def write_embedding_tensor_to_disk(vocab_path, output_path, sess, embedding):
 embeddings = sess.run(embedding)
 with open(output_path, 'w') as out_f:
  with open(vocab_path) as vocab_f:
   for (index, word) in enumerate(vocab_f):
    word = word.strip()
    embedding = embeddings[index]
    out_f.write((((word + ' DCTB ') + ' DCTB '.join([str(x) for x in embedding])) + '\n'))

def write_embedding_tensor_to_disk ( vocab_path , output_path , sess , embedding ) : embeddings = sess . run ( embedding ) with open ( output_path , 'w' ) as out_f : with open ( vocab_path ) as vocab_f : for ( index , word ) in enumerate ( vocab_f ) : word = word . strip ( ) embedding = embeddings [ index ] out_f . write ( ( ( ( word + ' DCTB ' ) + ' DCTB ' . join ( [ str ( x ) for x in embedding ] ) ) + '\n' ) )
writes tensor to output_path as tsv .